0

为什么 Firefox 可以获取“iframe”长度,但 Chrome 无法获取长度?

Firefox 获取“2”。Chrome 获取“0”。

Javascript:

$(document).ready(function(e) {
    var frames = window.parent.frames; 
    for (var i = 0; i < frames.length; i++) { 
          alert(frames[i].window.document.getElementsByTagName('body')[0].getElementsByTagName('iframe').length);
    }
}

HTML:

<frameset name="topFrame" id="topFrame" rows="112px,42px,7px,*" cols="*" border="0" framespacing="0">   
<frame src="top_1.html" name="topFrame" frameborder="no" scrolling="No" noresize="noresize" id="topFrame" title="topFrame"></frame>
<frame src="top_2.html" name="mainFrame" frameborder="no" scrolling="No" noresize="noresize" id="mainFrame" title="mainFrame"></frame>
<frame src="top_3.html" name="switch2Frame" frameborder="no" scrolling="No" noresize="noresize" id="switch2Frame" title="switch2Frame"></frame>
<frameset rows="40px,*" cols="*" border="0" framespacing="0">
    <frame src="tag.html" name="tagFrame" frameborder="no" id="tagFrame" title="tagFrame" scrolling="no"></frame>
        <frameset name="myFrame" id="myFrame" cols="200px,7px,*" rows="*" border="0" framespacing="0">          
            <frame src="left.html" name="leftFrame" frameborder="no" scrolling="No" noresize="noresize" id="leftFrame" title="leftFrame"></frame>       
            <frame src="switch.html" name="switchFrame" frameborder="no" scrolling="No" noresize="noresize" id="switchFrame" title="switchFrame"></frame>       
            <frame src="main.html" name="manFrame" class="manFrame" frameborder="no" scrolling="No" noresize="noresize" id="manFrame" title="test">
               <html xmlns="http://www.w3.org/1999/xhtml"><head>
               <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
               <title>Untitled Document</title>
               </head>
               <body>

              <iframe src="show.html" title="test" mid="105" frameborder="0" class="show" style="display: block;">
              </iframe>
              <iframe src="show_1.html" title="test" mid="200" frameborder="0" style="display: none;">
              </iframe>

              </body></html>
               </frame> 

        </frameset> 
    </frameset> 
</frameset><noframes></noframes>

4

0 回答 0