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)
精彩评论