iframe调用父javascript [英] iframe calling parent javascript

查看:72
本文介绍了iframe调用父javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否可以设置iframe,以便调用 window.parent.document 范围内的javascript函数?

Is it possible for me to setup an iframe so it calls a javascript function available in the window.parent.document scope?

推荐答案

如果我正确理解了这个问题,假设 functionName()是在iframe的父级中定义的,那么你可以在你的iframe中执行此操作:

If I am understanding the question correctly, assuming functionName() is defined within the parent of iframe, you can do this within your iframe:

window.parent.functionName();

只有父和iframe在同一个域上时才会有效: http://softwareas.com/cross-domain-communication-with-iframes

This will only work though, if both parent and iframe are on the same domain: http://softwareas.com/cross-domain-communication-with-iframes

这篇关于iframe调用父javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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