开发者

Can I use jquery selector quote child iframe's global variable?

I need create a iframe dynamically in my page,when I closed it ,it will be removed from my page. (In fact it jquery plugin "fancybox")

It always the last iframe.I want quote the page's global variable in the iframe.So I think the $("iframe:last").globalvariable would work.I put it in $(function(){……})开发者_JAVA百科 .However it does not.

I already know frame's id and name ,Can I achieve that through "id" or "name"?

Can I use selector quote child iframe's global variable?Or in this case,how can I achieve that ?

thank you


From the parents perspective:

var iFrameValue = $('#iframe').get(0).contentWindow.mySpecialFunction();

OR

var iFrameValue = $('#iframe').get(0).contentWindow.myLocalVariable;

From the iframe perspective

<script type="text/javascript">

var myLocalVariable = "hello";

function myLocalFunction () {
    return "hello";
}

</script>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜