码迷,mamicode.com
首页 > Windows程序 > 详细

Calling a parent window function from an iframe

时间:2016-04-19 11:35:52      阅读:213      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!