乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      iframe框架用JavaScript子頁(yè)面控制父頁(yè)面

       趨明 2012-03-24

      iframe框架用JavaScript子頁(yè)面控制父頁(yè)面


      parent.html  中的代碼為:

      <iframe marginwidth="0" framespacing="0" marginheight="0" frameborder="0" 
       name="uploadframe" id="uploadframe" src="c.html" scrolling="no" width="100" height="100" ></iframe>

      如想在c.html 中寫一些代碼去改變parent.html 中的一些內(nèi)容,以下代碼可作為參考:

      1、parent.window.frames 可返回parent.html 中所有的iframe;返回結(jié)果應(yīng)該是一個(gè)數(shù)組,用parent.window.frames[iframeId]可得到iframeId;

      2、用parent.document.getElementById('xxxx')可得到父里的xxxx,并改變相應(yīng)的值,例如:parent.document.getElementById('xxxx').className = 'test'; 

      3、如果我想在父中再創(chuàng)建一個(gè)元素,直接用parent.appendChild(yyyy)在firefox中是可以的,但在IE(最起碼IE6)是不行的; 所以,要把創(chuàng)建這個(gè)動(dòng)作放在父中來(lái)完成,在子中調(diào)用;

      例如:父中的代碼為:

      function addIframe(vNum){
       var iframe = document.createElement("iframe");
       iframe.setAttribute("marginwidth", "0"); 
       iframe.setAttribute("framespacing", "0"); 
       iframe.setAttribute("marginheight", "0"); 
       iframe.setAttribute("frameborder", "0"); 
       iframe.setAttribute("name", vNum); 
       iframe.setAttribute("id", vNum); 
       iframe.setAttribute("src", "http://www."); 
       iframe.setAttribute("scrolling", "no"); 
       iframe.setAttribute("width", "100"); 
       iframe.setAttribute("height", "100"); 
       document.getElementsByTagName('body')[0].appendChild(iframe);
       return;
      }

      子中可以這樣調(diào)用:

      <script>
      parent.addIframe('xxxx');
      </script>

      這樣就能完整創(chuàng)建一個(gè)元素了;

      4、同理,如果我想在子中把iframe給隱藏,本來(lái)想直接用parent.document.getElementById('uploadframe').style.display = 'none';來(lái)弄,但無(wú)論是在IE還是FIREFOX中,都是行不通的;只能用上邊的方法把動(dòng)作放在父中。

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多