top,parent,opener,iframe

來源:互聯網
上載者:User

1、top:分割視窗最高層次的瀏覽器視窗。採用如下方式進行訪問:top.frames['sub_frm']

2、parent:當前分割視窗的父視窗。採用如下方式訪問:parent.document.

3、opener:指用WINDOW.OPEN等方式建立的新視窗對應的原視窗。

4、iframe:在一個頁面含有某個iframe,其id="iframeA" name="IframeA",此時使用document.getElementById("IframeA")取到的是iframe標籤對象,通過該對象可以擷取iframe的各個屬性,例如src、frameborder、style等等,但是不能擷取到iframe所包含的子頁面的各個對象。如果使用document.frames("IframeA")取到的是iframe組件對象,通過該對象可以擷取到iframe所包含的頁面的子頁面的各個對象,例如子頁面的window對象,但是不能獲得iframe標籤得各個屬性,例如上面說到的src等等。請參看如下類似代碼:

1.html

<script>

  function check(){

    var obj1=document.getElementById("myframe");

    alert(obj1.src);

    //alert(obj1.window.document.myform.username.value);//Error

    var obj2=document.frames("myframe");

    alert(obj2.window.document.myform.username.value);

    //alert(obj2.src);//Error

  }

</script>

<body onload="check()">

  <iframe id="myframe" name="myframe" src="2.html" frameborder="3"

style="width:300;height:200;border-width:1;border-color:red;border-style:solid"></iframe>

</body>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.