从 iframe 调用父窗口函数 [英] Calling a parent window function from an iframe

查看:22
本文介绍了从 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>

参见 window.parent

返回对当前窗口或子帧的父级的引用.

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.

当窗口在