我正在开发一个项目,用于转换在 Internet Explorer 8 及更低版本中功能齐全的网站,但在 Firefox 或 Safari 中无法正常工作。
许多需要更改的内容都与 javascript 相关(即 IE 中存在但其他浏览器中不存在的方法)。
我想知道是否有人知道一个相当全面的常见事物列表,必须对其进行更改才能在所有浏览器上工作。
我从 quirksmode.org 开始,但我认为它不会拥有我正在寻找的一切。如果有人知道清单,请告诉我。
I am working on a project to convert a web site that is fully functional in Internet Explorer 8 and lower, but does not work well in Firefox or Safari.
A lot of what will need to be changed is going to be javascript-related (aka methods that exist in IE but not in other browsers).
What I want to know is whether anyone is aware of a fairly comprehensive list of common things that have to be changed to work accross all browsers.
I am starting with quirksmode.org but I don't think it will have quite everything I'm looking for. If anyone knows of a list please let me know.
发布评论
评论(4)
最好的选择是使用 Javascript 工具包/库,例如 jQuery、MooTools 或 Prototype。这样的决定将为您节省大量的工作,并且所有三个都在不断更新,这为您提供了很大程度的安全性,以应对未来的兼容性问题。特别是对于 DOM 操作或 AJAX,库是最佳选择。
如果您绝对不能使用它,怪异模式是一个好的开始。我从来没有找到任何一个足够全面的来源来阻止我针对每个问题领域跑回谷歌。
Your best option here is to go with a Javascript toolkit/library like jQuery, MooTools or Prototype. Such a decision will save you a monstrous amount of work, and all three are constantly being updated which gives you a large degree of safety against future compatibility issues. Especially for DOM manipulation or AJAX, a library is the way to go.
If you absolutely mustn't use one, quirksmode is a good start. I've never found any single source that is comprehensive enough to keep me from running back to Google for each problem area.
老实说,如果您没有丰富的跨浏览器开发经验,我怀疑修复应用程序的最佳方法是在每个目标浏览器上设置一个良好的测试环境并开始查找它的问题所在。无论如何,您最终都必须在每个目标浏览器上测试它,所以您不妨从那里开始。一旦找出哪些代码因特定错误而导致失败,您就可以进行更有针对性的搜索,以了解如何以跨浏览器的方式解决该问题。
随着时间的推移,您将建立一个良好的内部知识库,了解什么可以跨浏览器安全使用,什么不安全。即使经验丰富的开发人员仍然会在每个项目中遇到只有通过测试才能发现的新问题。不过,经验的一个优点是,您开始学习何时怀疑某些东西可能存在或不存在跨浏览器问题,并避免它(找到一种更安全的方法)或在使用它之前在多个浏览器中显式测试它。
我发现 http://jsfiddle.net 非常适合创建非常高效的独立测试用例,可以主动尝试其他浏览器或解决一直给您带来问题的问题。
正如其他人所说,各种浏览器库(如 jQuery 或其他库)的一个巨大优势是,它们已经为您解决了许多兼容性问题,并且一般来说,如果它们在库中记录了某个函数并且没有明确警告您关于跨浏览器问题,那么他们已经做好了准备工作以确保您的安全。
Quite honestly, if you don't have lots of experience doing cross-browser development, I suspect the best way to fix your app is to set up a good test environment on each target browser and starting finding where it breaks. You're eventually going to have to test it on each target browser anyway, so you might as well start there. Once you find out what code is failing you for a particular bug, you can do more targeted searches for how to work around that issue in a cross browser way.
You will, over time, build up a good internal knowledge base of what is safe to use in a cross browser way and what is not. Even experienced developers still run into new issues on every project that are only found with testing. One advantage of experience though is that you start to learn when to suspect that something might or might not have cross browser issues and either avoid it (find a safer way) or explicitly test it in several browsers before you use it.
I find that http://jsfiddle.net is awesome for creating very efficient self-contained test cases to either proactively try something in other browsers or to troubleshoot something that's been giving you a problem.
As others have said, one huge advantage of the various browser libraries like jQuery or others is that they have solved a lot of these compatibility issues for you and, in general, if they document a function in the library and don't explicitly warn you about cross-browser issues, then they've already done their homework to make it safe for you.
您可能还会发现使用 JavaScript 框架,例如 jQuery、ExtJs, 原型, Mootols, ...对于编写跨浏览器 JavaScript 非常有益。
You may also find out that using a javascript framework such as jQuery, ExtJs, Prototype, Mootols, ... would be very beneficial in writing cross browser javascript.
我强烈建议使用符合标准(例如 CSS3)的浏览器进行开发。
这个过程应该是:使用 FireFox 或 Chrome 进行开发,然后修复所有 IE 版本。
好吧,这就是我的日常面包……普通的是 IE b*tch,这让我有空闲时间……
I would strongly recommend to develop with a browser that meets the standards (e.g. CSS3).
The process should rather be: to develop with FireFox or Chrome - and fix all IE versions later on.
Well, this is my daily bread... and ordinary it's IE b*tch which makes me loose time...