我的代码如下,在iframe中生成JavaScript代码,然后运行它。它在FF和Chrome中运行正常,但无法在IE中运行。它说iframe中生成的jQuery代码在IE中不起作用,但在FF和Chrome中可用
属性 '$' 的值为null或undefined,而不是一个函数对象
任何想法?
这里是演示链接:http://www.gbtags.com/gb/demoviewer/466/empty/6b5417d7-4388-4e30-8055-0d15b10fa9a8.html.htm
<html>
<head>
<title>TEST iframe</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
</head>
<body>
Just a iframe
<div id="resulttab">
<iframe id="resultiframe" frameBorder="1" width="100%" height="120"></iframe>
</div>
<SCRIPT>
var iframe = $('#resultiframe')[0];
if(iframe.contentDocument) doc = iframe.contentDocument;
else if(iframe.contentWindow) doc = iframe.contentWindow.document;
else doc = iframe.document;
var js = '$(function(){console.log("hello")})';
var result = '<html><head></head><body>TEST JqUERY<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"><\/script><script type="text/javascript">' + js + '<\/script></body></html>';
doc.open();
doc.writeln(result);
doc.close();
</SCRIPT
</BODY>
</HTML>
是来到我的脑海里的唯一的事情它的塔IE挡住了'jquery'脚本试图用一个本地副本 – Jorge 2013-03-02 03:34:53
首先,请在下次发布aquestion时更好地格式化您的代码。并且semit off符合''.. 眩晕哟你的自我与在HTML标签帽不会做任何好事! – 2013-03-02 03:36:39
我尝试格式化代码,但do not't为我工作。 – terry 2013-03-02 03:38:20