在iframe中编写一些html和js,在IE中不起作用:没有定义$
write some html and js to a iframe,not working in IE:$ is not defined?
我给iframe写了一些html和js,在IE7/8/9中不起作用,错误消息是:$没有定义?
我的代码是:
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<meta charset="utf-8" />
<script type="text/javascript">
window.onload=function(){
var data='<html>'
<head>'
<meta charset="utf-8">'
<title>Demo</title>'
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"><'/script>'
<script type="text/javascript">'
$(function(){'
alert("abc");'
});'
<'/script>'
<'/head>'
<body>'
</body>'
</html>';
window.frames["code_result"].document.open();
window.frames["code_result"].document.write(data);
window.frames["code_result"].document.close();
}
</script>
</head>
<body>
<iframe id="code_result" frameborder="0" class="frame_result" name="code_result"></iframe>
</body>
</html>
谁能告诉我为什么?感谢
更新
这个错误只在IE78/9中显示,它在Chrome和FireFox 中运行良好
这不是加载I帧内容的代码。这是订单。只需将Iframe脚本封装在窗口onload函数中,就可以让jquery先加载。测试并在例如中工作
添加:
$(document).ready({
alert('123');
});
在运行代码之前,您需要在I帧中加载jquery。JQuery尚未加载。
相关文章:
- window.opener.document在ie中不起作用
- 为什么Telerik cdn在IE中不起作用
- JQuery脚本在IE中不起作用
- 默认光标在IE和Mozilla中不起作用
- Asp自定义验证器在IE-11中不起作用
- knockoutjsforeach在IE 9中不起作用
- 谷歌分析在IE中不起作用
- javascript中的SVG转换在IE 11中不起作用
- 用于播放背景音乐的嵌入式flash播放器在IE浏览器中不起作用
- 在IE中切换javascript不起作用的复选框
- JQuery日期选择器在IE 7上不起作用
- HTML表单在IE中不起作用
- Javascript style.background在IE中不起作用
- 对<asp:IE 10的TextBox;不起作用
- Javascript/AAJAX在Opera中不起作用,在FF/IE/Chrome中完美工作
- SPA异步调用在IE 11中不起作用
- 脚本在IE 9中不起作用
- ng-单击在IE中不起作用的选项选择Angularjs
- html2canvas 代码不起作用 IE 11
- 隐藏选项不起作用IE