开发者

how to access element id which belongs to another html page?

开发者 https://www.devze.com 2023-03-26 17:18 出处:网络
i have a javascript problem there are three html page like \'page1.html\', \'anotherPage.html\' and anotherPage.html

i have a javascript problem

there are three html page like 'page1.html', 'anotherPage.html' and anotherPage.html

FOR page1.html

<div id='mainFrame'></div>

<ul><li onclick="updateFrame(id,"anotherPage.html");"><a href="javascript:;"></a></li></ul>

FOR anotherPage.html

<ul><li onclick="updateFrame(id,anotherPage2);"><a href="javascript:;"></a></li></ul>

my javascript function:

function updateFrame(id,url){
document.getElementById(id).innerHTML="<iframe scrolling='no' style='height:2000px;position:abso开发者_开发百科lute;width:100%;height:100%;left:10px;border-style:none' src=\" "+ url+ "\"></iframe>";} 

The problem is that when i called java script in iframe, javascript did not find the parent document id. How can i access the parent document id ? (Parent document is another html page in this case)

Thanks.


parent.document.getElementById('myControlId')
0

精彩评论

暂无评论...
验证码 换一张
取 消