<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta forua="true" http-equiv="Cache-Control" content="max-age=0" /></head>
<card title="父页面调用iframe里的js函数(contentWindow)和dom元素(contentDocument)" id="card1">
<p> 游客</p><p>
标题:父页面调用iframe里的js函数(contentWindow)和dom元素(contentDocument)<br/>
正文:<br/>
父页面调用iframe里的js函数：document.getElementById('iframedemo').contentWindow.demofunction(); //与下边一句等价 window.frames['iframedemo'].contentWindow.demofunction(); 其中iframedemo是iframe的id，demofunction是iframe里的js函数名父页面调用iframe里的dom元素：document.getElementById('iframedemo').contentDocument.getElementById(&amp;quot;INPUT_Text&amp;quot;).value; //与下边一句等价 window.frames['iframedemo'].contentDocument.getElementById(&amp;quot;INPUT_Text&amp;quot;).value; 其中iframedemo是iframe的id注意事项：contentWindow 兼容各个浏览器，可取得子窗口的 window 对象。contentDocument Firefox 支持，&amp;gt; ie8 的ie支持。可取得子窗口的 document 对象。题外话：那么从子页面(iframe)调用父页面，就用window.parent;如果从页面A中，执行了window.open(url);打开的页面B， 那么页面B访问页面A，就用window.opener;如果跨域访问父页面或者子页面的js函数或dom，会有拒绝访问的情况，一般要保证同域，document.domain=&amp;quot;camnpr.com&amp;quot;;更多关于页面之间跳转来跳转去、访问来访问去的话题，欢迎留言。<br/><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=622&amp;Page=1">[&lt;&lt;]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=622&amp;Page=1">[[1]]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=622&amp;Page=1">[&gt;&gt;]</a><br/>
<br/>
<a href="wap.asp?act=Com&amp;id=622">查看评论(0)</a><br/>
<a href="wap.asp?act=AddCom&amp;inpId=622">发表评论</a><br/><br/>

<br/>

<br/>
<a href="http://camnpr.com/wap.asp">首页</a>
</p>
</card>
</wml>