900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 实现 iframe 子页面调用父页面中的js方法

实现 iframe 子页面调用父页面中的js方法

时间:2023-03-24 14:54:55

相关推荐

实现 iframe 子页面调用父页面中的js方法

父页面:index.html(使用iframe包含子页面child.html)

<html><head><script type="text/javascript"><!--function toshow(msg){alert("这里是父页面:"+msg);}// --></script></head><body><iframe background="blue" src="child.html" mce_src="child.html"></iframe></body></html>

子页面child.html(调用父页面toshow方法)

<html><head><script type="text/javascript"><!--function doparent(){window.parent.toshow('ccccchild');}// --></script></head><body>This is child frame!!<input type="button" value="请点击" οnclick='doparent()'></input></body></html>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。