Is it in general very hard to port JavaScript code to another browser platform?
views:
267answers:
7Not if you use a library like jQuery or Prototype.
But if you don't, then it can be a real bitch. See quirksmode for the everything cross-browser.
Here are some common problems:
- eventing
- AJAX
id
vs.name
iframe
s- ... i could keep going but ppk (quirksmode) says it best
You don't need to "port" javascript, since it runs in every major (graphical) browser.
Cross-browser issues are a massive pain for JS developers, but the pain is being eased by libraries such as jQuery which smooth out a lot of the key differences.
The JavaScript shuold run fine for you ... unfortunately, tho', different browsers have different names for the same thing, etc. Try jQuery at jquery.com.
No, cross browser issues are extremely minor with regard to JavaScript. The most common differences are the IE expects use of the className method to change a class attribute instead of the getAttribute function. IE also requires a special way of entering the style block in the head, but otherwise cross browser issues are extremely rare in all vaguely modern browsers.
With libraries like jQuery, the compatibility issues are pretty much history. However, they won't help the least with CSS and DOM problems, which can cause horrific headaches with IE6.
If you're coding pretty simple JavaScript or using established libraries such as JQuery or Mootools then you'll probably not suffer any issues in regards to browser compatibility even in IE6 as these libraries have been thoroughly designed to comply to legacy browsers.