开发者

jQuery scoping issues between parent and iframe

I use jQu开发者_StackOverflow社区ery to create an iframe element which onLoad calls one of the parent's jQuery functions. This causes $ is not defined for the parent when it calls additional jQuery functions.

It seems as if the iframe has caused a descoping if the parent's jQuery.

The iframe is not a page (src="about:blank").

I think the iframe needs its own JavaScript/jQuery Environment but am having difficulty including it.

Any ideas? Thanks.


try this inside the iframe:

<script type="text/javascript">
    var $ = window.parent.$;
</script>

This will allow the child window (assuming it is under the same domain) to use the parent's $ variable (or whatever jQuery is set to)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜