首页 > Windows开发 > 详细

Calling a parent window function from an iframe

时间:2016-04-19 11:33:21      阅读:335      评论:0      收藏:0      [点我收藏+]

I want to call a parent window JavaScript function from an iframe.

<script>function abc(){
        alert("sss");}</script><iframeid="myFrame"><aonclick="abc();"href="#">Call Me</a></iframe>

Answers

 

 

 

<aonclick="parent.abc();"href="#">Call Me </a>

See 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.

 

When a window is loaded in an <iframe><object>, or <frame>, its parent is the window with the element embedding the window.

 

I want to call a parent window JavaScript function from an iframe.

<script>function abc(){
        alert("sss");}</script><iframeid="myFrame"><aonclick="abc();"href="#">Call Me</a></iframe>
shareedit
 
    
I won‘t able to show anything right now (2016), I don‘t know if the older bower would support any – DotKu Mar 21 at 19:04

8 Answers

up vote274down voteaccepted
<aonclick="parent.abc();"href="#">Call Me </a>

See 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.

When a window is loaded in an <iframe><object>, or <frame>, its parent is the window with the element embedding the window.

Calling a parent window function from an iframe

原文:http://www.cnblogs.com/sdream/p/5407115.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!