Reputation: 36020
In a web application, writing javascript is a common work, and I have tried to create cross-browser code.
If I try my best to make it work in Firefox, then it does not work in IE.
So I wonder if there are any rules or experiences from you guys to tell me how to write cross-browser code?
UPDATE:
Sorry I forget to make it sure that we can not use jquery in my current application since we are usng prototype1.4(which is to difficult to use than jquery),so most time we use the native javascript.
Upvotes: 1
Views: 4844
Reputation: 41872
Have you tried jQuery? It's a great cross-browser JavaScript library that's very popular for JavaScript development.
Upvotes: 1
Reputation: 1
Have you tried to use jQuery?
It would allow you to isolate your own javascript code and write cross-browser code
Upvotes: 0
Reputation: 3758
I'd recommend CoffeeScript - http://jashkenas.github.com/coffee-script/
It allows you to write in a safe way without worrying about global vars and all the quirks of JS. It's worth a look.
Upvotes: 0
Reputation: 943108
The vast majority of problems will go away if you:
Most of the rest will go away if you use a library that abstracts away the differences. There are plenty of small specialized ones as well as kitchen sink options such as YUI and jQuery.
Upvotes: 6
Reputation: 120168
I would use any of the plethora of js libraries out there, such as jquery, sencha, sproutcore, etc.
They go thru great pains to make cross-browser issues null and void. You always need to test in al browsers that you want to support, but these libraries are excellent and do most if not all of the work for you.
Upvotes: 0