admin管理员组

文章数量:1426292

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:absolute;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.

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:absolute;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.

Share Improve this question edited Aug 7, 2011 at 15:05 s.onal asked Aug 7, 2011 at 15:00 s.onals.onal 271 gold badge2 silver badges6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 1
parent.document.getElementById('myControlId')

本文标签: javascripthow to access element id which belongs to another html pageStack Overflow