从 iframe 调用父窗口函数 [英] Calling a parent window function from an iframe
本文介绍了从 iframe 调用父窗口函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从 iframe 调用父窗口 JavaScript 函数.
I want to call a parent window JavaScript function from an iframe.
<script>
function abc()
{
alert("sss");
}
</script>
<iframe id="myFrame">
<a onclick="abc();" href="#">Call Me</a>
</iframe>
推荐答案
<a onclick="parent.abc();" href="#" >Call Me </a>
返回对当前窗口或子帧的父级的引用.
Returns a reference to the parent of the current window or subframe.
如果一个窗口没有父窗口,则其父属性是对自身的引用.
If a window does not have a parent, its parent property is a reference to itself.
当窗口在 、
或
中加载时,其父窗口为元素嵌入窗口的窗口.
When a window is loaded in an <iframe>
, <object>
, or <frame>
, its parent is the window with the element embedding the window.
这篇关于从 iframe 调用父窗口函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文