javascript Backbone.js Web 应用程序在 Internet Explorer 上无法使用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9235447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Backbone.js web application is unusable on Internet Explorer
提问by Shiv Deepak
I have developed my web application w/o testing it on IE. Though it worked fine on all the browsers viz. Chrome, Firefox, Safari but when it comes to IE there is a strange behavior.
我已经开发了我的 Web 应用程序,而无需在 IE 上对其进行测试。虽然它在所有浏览器上都运行良好。Chrome, Firefox, Safari 但是当涉及到 IE 时有一个奇怪的行为。
Sometimes the app loads and some times a blank page is loaded as if none of the "bind" events had any effect.
有时会加载应用程序,有时会加载空白页面,就好像“绑定”事件都没有任何效果。
And the lucky times when the app loads, the nav panel is partially missing. I can't show you the code right now coz I am not sure what part to show and where I am doing it wrong.
幸运的是,当应用程序加载时,导航面板部分丢失。我现在无法向您展示代码,因为我不确定要展示什么部分以及我在哪里做错了。
If anyone of you can provide me a checklist of what to check and what tools would be ideal for debugging on IE then it would be great.
如果你们中的任何人都可以向我提供要检查的内容以及哪些工具最适合在 IE 上进行调试的清单,那就太好了。
And if anyone of you can tell me most common backbone.js bugs on IE then that too would help.
如果你们中有人能告诉我 IE 上最常见的 Backbone.js 错误,那也会有帮助。
PS: Version of IE I am testing with: IE8
PS:我正在测试的IE版本:IE8
回答by Gazler
Some issues in IE are:
IE中的一些问题是:
Trailing commas on Objects:
对象的尾随逗号:
E.g.
例如
App.model = Backbone.Model.extend({
url: "/foo/bar",
validate: function() {
},
});
Should be:
应该:
App.model = Backbone.Model.extend({
url: "/foo/bar",
validate: function() {
}
});
The use of functions that are not available in IE such as lastIndexOf()
使用IE中没有的功能如 lastIndexOf()
A third thing to check for is invalid HTML. IE can be particularly picky about your HTML structure. Be sure that all open tags either have a matching close tag, or are self closing with />
要检查的第三件事是无效的 HTML。IE 可能对您的 HTML 结构特别挑剔。确保所有打开的标签要么有一个匹配的关闭标签,要么用/>
If you are using JSON methods such as JSON.parse()
and JSON.stringify()
then be sure to include a JSON library such as JSON2.
如果您使用 JSON 方法JSON.parse()
,JSON.stringify()
然后确保包含一个 JSON 库,例如JSON2。
回答by benekastah
If you are running Windows 7, you should upgrade to IE9. Then you can use IE developer tools to debug your page. It is similar to using firebug or the webkit developer tools. With the IE developer tools, you can emulate back to IE7 as well.
如果您运行的是 Windows 7,则应升级到 IE9。然后您就可以使用 IE 开发人员工具来调试您的页面。它类似于使用 firebug 或 webkit 开发人员工具。使用 IE 开发人员工具,您也可以模拟回 IE7。
If you are running XP, you should get Windows 7 and then upgrade to IE9.
如果您运行的是 XP,则应该安装 Windows 7,然后升级到 IE9。
Also, you should use something like es5 shims. This provides javascript functionality that is present in modern browsers, but not old versions of IE.
此外,您应该使用类似es5 shims 的东西。这提供了现代浏览器中存在的 javascript 功能,但不是旧版本的 IE。
回答by Abhinav
Dynamic Binding is not supported by MSIE <10 ,but its working out in MSIE 10. The jQuery codes like .show(),.hide() might work in static binding ,but in case of Backbone ,Node like frame work using dynamic binding,templating and other technology might not work on it MSIE 10 will be able to catch on it
MSIE <10 不支持动态绑定,但它在 MSIE 10 中工作。像 .show(),.hide() 这样的 jQuery 代码可能在静态绑定中工作,但在 Backbone 的情况下,使用动态绑定的 Node 之类的框架工作,模板和其他技术可能无法使用 MSIE 10 将能够赶上它
回答by Conor Power
I have found that your HTML templates need to be well formed HTML. Chrome and Firefox seem much more forgiving but with IE 8, the inclusion of a bad caused a blank view to be displayed.
我发现您的 HTML 模板需要格式正确的 HTML。Chrome 和 Firefox 似乎更宽容,但对于 IE 8,包含 bad 会导致显示空白视图。