javascript 我的 jQuery 不适用于 IE11

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20110078/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 17:44:30  来源:igfitidea点击:

My jQuery is not working with IE11

javascriptjqueryhtmlinternet-explorerconsole

提问by user2660811

So I got three pieces of code to load stuff into div and do other things. But it doesn't work with Internet Explorer, I checked IE11 console and that's what I got

所以我得到了三段代码来将东西加载到 div 中并做其他事情。但它不适用于 Internet Explorer,我检查了 IE11 控制台,这就是我得到的

SCRIPT5009: '$' is undefined

That's odd, in every other browser it works fine, I tried to google it but didn't find any solution to this.

这很奇怪,在所有其他浏览器中它都可以正常工作,我试图用谷歌搜索它但没有找到任何解决方案。

Here's my jQuery:

这是我的 jQuery:

<script type="text/javascript">
    $('#description').load('descr/portDefault.htm');
    $('#portNav').load('menus/default.htm');

@edit

@编辑

I guess I forgot to put the entire code, here it is: http://pastebin.com/xCL1e7FhThis html is an iframe in another html file if that makes a difference.

我想我忘了把整个代码放在这里:http: //pastebin.com/xCL1e7Fh如果这有区别的话,这个 html 是另一个 html 文件中的 iframe。

回答by Bob Lokerse

In my case I thought I had the fix with the compatability set in the meta tag.

就我而言,我认为我已经修复了元标记中设置的兼容性。

<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1" />

It worked, but that triggered me to check compatablity settting in IE11. For a previous project I had added localhost to the list in the Compatability View Settings.

它有效,但这促使我检查 IE11 中的兼容性设置。对于以前的项目,我已将 localhost 添加到兼容性视图设置的列表中。

Cleared the list and it works well now (without the meta tag).

清除列表,现在运行良好(没有元标记)。