IE9 js加载顺序和JQuery [英] IE9 js load order and JQuery

查看:76
本文介绍了IE9 js加载顺序和JQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个很容易解决的问题,但这是我的难题.

以下简单示例在IE9中产生错误.我已经使用IE9的开发人员页面来监视网络负载,并且看起来IE在加载/评估所包含的javascript之前正在加载并执行正文脚本.

我尝试了通过搜索答案找到的所有各种技巧,包括添加<meta charset="UTF-8" /><meta http-equiv="x-ua-compatible" content="IE8"/>

<html>
<head>
  <title>Demo of IE suckiness</title>
  <script type='text/javascript' 
      src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'></script>
  </head>
  <body>
This works in every browser but not IE9. IE gives the error:
<pre>
Line: 9
Error: The value of the property '$' is null or undefined, not a Function object
</pre>

<script type="text/javascript" defer="defer">
$(document).ready(function(){
  alert("Must not be IE");
});
</script>
</body>
</html>

我有一个解决方法.将准备好的脚本移到<body onload="ready()">,但是我不敢相信这对于IE9来说是坏的,我一定做错了什么,只是看不到它.

解决方案

我遇到了类似的问题.我通过 重置我的所有IE9设置 进行了修复.
我认为通过提高安全性或隐私性可以破坏从外部页面加载jquery.

This seems like an easy problem to solve, but it's kickin my ass.

The following simple example produces an error in IE9. I've used IE9's developer page to monitor network loading and it looks like IE is loading and executing the body's script before the included javascript is loaded/evaluated.

I've tried all the various tricks found via searching for answers including adding <meta charset="UTF-8" /> and <meta http-equiv="x-ua-compatible" content="IE8"/>

<html>
<head>
  <title>Demo of IE suckiness</title>
  <script type='text/javascript' 
      src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'></script>
  </head>
  <body>
This works in every browser but not IE9. IE gives the error:
<pre>
Line: 9
Error: The value of the property '$' is null or undefined, not a Function object
</pre>

<script type="text/javascript" defer="defer">
$(document).ready(function(){
  alert("Must not be IE");
});
</script>
</body>
</html>

I have a work-around. Move the ready script to <body onload="ready()">, but I can't believe this is broken for IE9, I must be doing something wrong and just can't see it.

解决方案

I had a similar problem. I fixed it by resetting all my IE9 settings.
I think by cranking up security or privacy it can break jquery loading from an external page.

这篇关于IE9 js加载顺序和JQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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