简体   繁体   English

JS跨浏览器的不一致/差异

[英]JS cross browser inconsistencies/differences

There are lots of DOM/CSS inconsistencies between browsers. 浏览器之间存在大量DOM / CSS不一致。 But how many core JS differences are there between browsers? 但浏览器之间存在多少核心JS差异? One that recently tripped me up is that in Firefox, setTimeout callback functions get passed an extra parameter (https://developer.mozilla.org/en/window.setTimeout). 最近让我失望的是,在Firefox中,setTimeout回调函数会传递一个额外的参数(https://developer.mozilla.org/en/window.setTimeout)。

Also, now that browsers are implementing new functions (eg 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). 此外,现在浏览器正在实现新功能(例如Array.map),如果您尝试编写必须适用于所有浏览器的代码(甚至回到IE6),那么知道您可以/不可以使用它会让人感到困惑。

Is there a website that cleanly organizes these types of differences? 是否有一个网站干净地组织这些类型的差异?

I find QuirksMode and WebDevout to have the best tables regarding CSS and DOM quirks. 我发现QuirksModeWebDevout拥有关于CSS和DOM怪癖的最佳表格。 You can bridge those incompatibilities with jQuery. 您可以使用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. Paul Irish也推出了这个很棒的列表 ,其中包括几乎所有你需要的polyfill,包括ES5方法,如Array.map。

Well, I'm going to open up a CW: 好吧,我打算开一个CW:

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 compatibility doc section that outlines supported browsers and known issues. 如果你使用jQuery,那么有一个很好的浏览器兼容性文档部分 ,它概述了支持的浏览器和已知问题。 I just deal with issues as they come 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. 当您对特定主题进行快速搜索时,很容易发现问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM