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

查看:24
本文介绍了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 的父级中定义的,你可以在你的框架:

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天全站免登陆