Not able to load jQuery in Internet Explorer on lo

2019-03-07 03:25发布

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.

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>

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

I get -- no jquery -- SCRIPT5007: The value of the property '$' is null or undefined, not a Function object in the console.

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

Network tab is not displaying any errors.

1条回答
欢心
2楼-- · 2019-03-07 04:06

Quote OP:

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

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.

References:

查看更多
登录 后发表回答