我有一个包含iframe的页面.我的iframe页面是iframe.php,我的主页面是main.php,当我直接加载iframe.php我的jquery代码执行正常,但是当我加载main.php(其中包含iframe.php作为iframe)时,我收到错误" $未定义".
这可能是因为main.php和iframe.php都使用了
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
Run Code Online (Sandbox Code Playgroud)
如果是这样,如何在iframe页面中使用jquery而不包括此行?
Dev*_*man 15
我想到了.在我使用的iFrame中
var $ = parent.$;
Run Code Online (Sandbox Code Playgroud)
以及任何jquery调用文档的上下文.即
$("#element", document).doStuff();
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为我拥有它的原始方式(两个页面都包含jquery)在Safari for Mac中运行良好但在Firefox中它给了我错误
错误:c.defaultView.getComputedStyle(h,null)为null源文件:http://code.jquery.com/jquery-latest.pack.js 行:16
归档时间: |
|
查看次数: |
14068 次 |
最近记录: |