IE上开发的Javascript的典型原因是什么? [英] What are the typical reasons Javascript developed on IE fails on Firefox?

查看:110
本文介绍了IE上开发的Javascript的典型原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常遇到的问题与这篇文章。也就是说,我已经在仅为Internet Explorer设计的遗留应用程序中提供了代码,我需要让它在Firefox中工作。

I often suffer from the problem opposite what's described in this post. That is, I've got code in a legacy application designed only for Internet Explorer and I need to get it to work in Firefox.

例如,我最近在一个大量使用手动模拟点击事件的应用程序,如下所示:

For example, I recently worked on an app that made heavy use of manually simulating click events, like this:

select.options[0].click();

...完全打破了Firefox中的应用程序。但是你不会在另一个问题的答案中找到这些信息,因为如果您的应用程序首先定位到Firefox,那么您甚至不会尝试。

...which completely broke the application in Firefox. But you wouldn't find that information in the answers to the other question, because that's not something you'd ever even attempt if your app first targeted Firefox.

其他什么迁移到现代浏览器时,开发人员应该更新旧版IE浏览器吗?

What other things should a developer updating a legacy IE-only application look for when migrating to modern browsers?

推荐答案

以下是我以前的研究发现。我已经看到这些问题阻止了真实世界的应用程序在Firefox中工作。请自由编辑。

Here's what my previous research uncovered. I've seen each of these issues prevent a real-world application from working in Firefox. Please feel free to edit.

document.createElement 应该只使用一个标签名称,但IE可以让
传递任意的HTML(带有属性等)

document.createElement should take only a tag name, but IE lets you pass arbitrary HTML (with attributes, etc)

  • http://msdn.microsoft.com/en-us/library/ms536389(VS.85).aspx

document.getElementById 只能找到给定的 id
的元素,但IE也返回给定的元素名称

  • http://msdn.microsoft.com/en-us/library/ms536437(VS.85).aspx

IE为DOM元素创建隐式全局变量,但是在Firefox中引用一个元素会产生以下警告:

IE creates implicit global variables for DOM elements, but referencing an element this way in Firefox produces the following warning:


Eleme在
全局范围内由ID / NAME引用。使用W3C标准
document.getElementById()。

"Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead."



查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆