无法在localhost(WAMP)的Internet Explorer中加载jQuery [英] Not able to load jQuery in Internet Explorer on localhost (WAMP)

查看:100
本文介绍了无法在localhost(WAMP)的Internet Explorer中加载jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一段标准的HTML,但是无法让jQuery在IE上运行. 我尝试了IE10和IE11,以及IE10中模拟的IE8和9.

I have a standard piece of HTML but cannot get jQuery to work on IE. I tried IE10 and IE11, as well as IE8 and 9 emulated in IE10.

我什至尝试使用 HTML5Boilerplate 中的代码.我正在测试jquery,但未加载.

I even tried using the code from HTML5Boilerplate. I am testing for jquery and is not loaded.

代码可在所有其他浏览器中使用.我在本地而不是服务器上运行它.

Code works in all other browsers. I am running this on my local, not on a server.

<!DOCTYPE html>
<html>

<head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>

<body>

    <script type="text/javascript">
        if (window.jQuery) {
            // jQuery is available.
        } else {
            console.log("-- no jquery --");
        }
    </script>

</body>

</html>

为什么我不能在IE中使用它?

Why can't I get this to work in IE ?

我在控制台中看到-- no jquery -- SCRIPT5007: The value of the property '$' is null or undefined, not a Function object.

此外,如果我在控制台中键入jQuery().jquery,我会得到undefined.

Also, if I type jQuery().jquery in the console, I get undefined.

网络"标签未显示任何错误.

Network tab is not displaying any errors.

推荐答案

引用OP:

我正在本地运行,而不是在服务器上运行

I am running this on my local, not on a server

然后,您需要指定一个方案,否则浏览器可能会假设src="//domain.com/script.js"src="file://domain.com/script.js",由于您不在本地托管此资源,因此这会中断.

Then you need to specify a scheme, otherwise the browser may assume that src="//domain.com/script.js" is src="file://domain.com/script.js", which will break since you're not hosting this resource locally.

参考:

https://stackoverflow.com/a/7818464/594235

https://stackoverflow.com/a/11372220/594235

这篇关于无法在localhost(WAMP)的Internet Explorer中加载jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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