admin管理员组文章数量:1332395
In a web application, writing javascript is a mon 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.
In a web application, writing javascript is a mon 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.
Share Improve this question edited May 14, 2011 at 12:52 hguser asked May 14, 2011 at 12:36 hguserhguser 36.1k55 gold badges172 silver badges302 bronze badges5 Answers
Reset to default 6The vast majority of problems will go away if you:
- Have a Doctype that triggers standards mode
- Follow the specifications and avoid proprietary browser extensions
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.
Have you tried jQuery? It's a great cross-browser JavaScript library that's very popular for JavaScript development.
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.
I'd remend CoffeeScript - http://jashkenas.github./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.
Have you tried to use jQuery?
It would allow you to isolate your own javascript code and write cross-browser code
本文标签: How to write crossbrowser javascript codeStack Overflow
版权声明:本文标题:How to write cross-browser javascript code - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742252289a2440987.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论