script_Javscript调用iframe框架页面中函数

时间:2019-07-03  来源:php函数  阅读:

访问iframe里面的函数

document.getElementById("commentIframe").contentWindow.hasLogined();

commentIframe为iframe的id.

要在 window.onload里面执行

例子

 代码如下

1.html

aa

2.html 页面

<script language="javascript" type="text/javascript">
 function MyNext()
 {
   alert(1);
 }
</script>


在1.htm中点击test按钮,可以使2.htm(iframe页面)中mybutton按钮失效.就这么简单,呵呵.如果要调用2.htm中的JS函数这样写:
self.frames["a"].funtionname(param)

在1.htm中调用2.htm中的JS函数:iframe2.showInfo();


例子

说明:假设有2个页面,index.html和inner.html。其中index.html中有一个iframe,这个iframe的src指向inner.html。

我们现在要做的就是:

1.在index.html中调用inner.html上的一个js方法
2.在inner.html中调用index.html上的一个js方法

实现代码如下:

index.html

 代码如下



<script type="text/javascript">
function ff(){
alert(">>this is index"s js function  index.html");
}
</script>



This is index page.






inner.html

 代码如下



<script type="text/javascript">
function sonff(){
alert(">>this is inner page"s js function");
}
</script>



This is inner page.




script_Javscript调用iframe框架页面中函数

http://m.bbyears.com/jiaocheng/56273.html

推荐访问:
相关阅读 猜你喜欢
本类排行 本类最新