iframe中的jQuery无法在IE中运行 [英] jQuery in iframe not working in IE

查看:96
本文介绍了iframe中的jQuery无法在IE中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含jQuery的iframe内容,而iframe中内容的jQuery部分在IE中不起作用(未使用的部分jQuery工作正常,一切在Chrome和Firefox中运行良好)。

I have an iframe content that includes jQuery, and the jQuery part of the content in iframe is not working in IE (the part that is not used jQuery is working fine, and everything works fine in Chrome and Firefox).

以下是代码:

<!DOCTYPE html>
<html>
<head>
    <title>iframe content</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <h1>This heading is showing up just fine.</h1>
    <div id="jQuery-generated-content">
           <!-- content dynamically generated by jQuery plugin This part is not showing in iframe in IE -->
    </div>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">   </script>
    <script src="pathTojQueryPlugin.js"></script>
    <script type="text/javascript">
        jQuery.codeToInitiatePlugin
    </script>

</body>
</html>

我尝试在主体标签后面的头部插入jQuery代码,包括相对路径和绝对路径,但没有运气。如果有人知道任何变通办法或IE导致IE无法读取jQuery,我将不胜感激。

I tried inserting jQuery code in the head, right after the body tag, with both relative and absolute path, but no luck. I would greatly appreciate if anyone knows any workarounds for this or what's causing IE to not read jQuery.

提前致谢!

推荐答案

前段时间我也遇到过同样的问题。导致该问题是因为IE无法从iframe中访问jquery库,因此无法读取jquery代码。唯一的解决方法是将jquery代码转换为javascript。

I also encountered the same problem some time ago. The problem is caused because IE is unable to access the jquery library from within the iframe and thus it cannot read the jquery code. The only walkaround would be to convert the jquery code to javascript.

更新:

使用不同版本的jQuery也可以解决问题。或者可以使用不同的jQuery库。

Using a different version of jQuery can also solve the problem. Or a different jQuery library may be used alternatively.

这篇关于iframe中的jQuery无法在IE中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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