admin管理员组

文章数量:1292119

There are lots of DOM/CSS inconsistencies between browsers. But how many core JS differences are there between browsers? One that recently tripped me up is that in Firefox, setTimeout callback functions get passed an extra parameter (.setTimeout).

Also, now that browsers are implementing new functions (e.g. Array.map), it can get confusing to know what you can/can't use if you are trying to write code that must work on all browsers (even back to IE6).

Is there a website that cleanly organizes these types of differences?

There are lots of DOM/CSS inconsistencies between browsers. But how many core JS differences are there between browsers? One that recently tripped me up is that in Firefox, setTimeout callback functions get passed an extra parameter (https://developer.mozilla/en/window.setTimeout).

Also, now that browsers are implementing new functions (e.g. Array.map), it can get confusing to know what you can/can't use if you are trying to write code that must work on all browsers (even back to IE6).

Is there a website that cleanly organizes these types of differences?

Share Improve this question asked Sep 14, 2011 at 20:01 Davis DimitriovDavis Dimitriov 4,2573 gold badges33 silver badges46 bronze badges 5
  • One of the purposes of jquery is to bridge the differences between the browser, and give the programmer a browser-independent API. It's not an answer, but a good workaround. Also, see here for a list of (some) differences: stackoverflow./questions/703993/… – Eran Zimmerman Gonen Commented Sep 14, 2011 at 20:04
  • 2 @Eran, jQuery addresses DOM/CSS inconsistencies far more than the inconsistencies of the language itself. – Kirk Woll Commented Sep 14, 2011 at 20:05
  • Google for the words "es5 shim" if you're worried about new features. – Incognito Commented Sep 14, 2011 at 20:10
  • this is a good question, but don't you think it might be a little too broad for stackoverflow? seems like it's more of a general discussion thread than a specific coding question. – Ben Lee Commented Sep 14, 2011 at 20:10
  • 1 @Ben Lee well, my question was asked in the hopes that there was a website I had missed that spells some of this out that someone could point out, but if the answer turns out to be "well, let's e up with the list" then I could agree with your point – Davis Dimitriov Commented Sep 14, 2011 at 20:12
Add a ment  | 

3 Answers 3

Reset to default 5

I find QuirksMode and WebDevout to have the best tables regarding CSS and DOM quirks. You can bridge those inpatibilities with jQuery. There is also this great list started by Paul Irish which includes pretty much any polyfill you could ever need, including ones for ES5 methods such as Array.map.

There doesn't appear to be anything out there that clearly outlines all these issues (very surprising actually). If you use jQuery there is a nice browser patibility doc section that outlines supported browsers and known issues. I just deal with issues as they e up (as you should be browser testing in all cases anyways) and you can document them if you want to make sure you are coding correctly or if you run into issues and need to know fixes. It's easy to find issues when you do a quick search on a particular topic.

Well, I'm going to open up a CW:

  • Prior to Firefox 4 Function.apply only accept an Array, not an array-like object. Ref MDC: Function.apply
  • Some engines (which ones?) promote the result of String.prototype methods from string to String. Ref a String.prototype's "this" doesn't return a string?
  • Firefox 4 may insert "event loops" into seemingly synchronous code. Ref Asynchronous timer event running synchronously ("buggy") in Firefox 4?
  • Earlier Firefox versions would accept a trailing , in object literals. Ref trailing ma problem, javascript (Seems "fixed" in FF6).
  • Firefox and IE both treat function-expression productions incorrectly (but differently).
  • Math.round/Math.toFixed. Ref Math.round(num) vs num.toFixed(0) and browser inconsistencies
  • The IE vs. W3C Event Model -- both are missing events/features of the other.

本文标签: javascriptJS cross browser inconsistenciesdifferencesStack Overflow