javascript iframe内的函数调用实现方法

  作者:bea

sxmsxm.html 代码如下: <script> function sonfun() { alert('ok'); } </script> main.html 代码如下: <iframe id="sxm" src="sxmsxm.html" width='100' height='100'></iframe> 在main.html中执行 sxmsxm.html中的sonfun() 有两种方式 1、 sxm.son
sxmsxm.html



代码如下:


<script> function sonfun() { alert('ok'); } </script>




main.html


代码如下:


<iframe id="sxm" src="sxmsxm.html" width='100' height='100'></iframe>



在main.html中执行 sxmsxm.html中的sonfun() 有两种方式

1、 sxm.sonfun()

2、document.getElementById("sxm").contentWindow.sonfun();


有用  |  无用

猜你喜欢