[英]how do I access a HTML element from javascript using id,the html element belongs to another html document
[英]how to access element id which belongs to another html page?
我有一個JavaScript問題
對於page1.html
<div id='mainFrame'></div>
<ul><li onclick="updateFrame(id,"anotherPage.html");"><a href="javascript:;"></a></li></ul>
對於anotherPage.html
<ul><li onclick="updateFrame(id,anotherPage2);"><a href="javascript:;"></a></li></ul>
我的JavaScript函數:
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>";}
問題是,當我在iframe中調用Java腳本時,javascript找不到父文檔ID。 如何訪問父文檔ID? (在這種情況下,父文檔是另一個html頁面)
謝謝。
parent.document.getElementById('myControlId')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.