JavaScript :当有很多帧时如何调整窗口大小

javascript : how to resize window when there are many frames

本文关键字:何调整 调整 窗口大小 JavaScript      更新时间:2023-09-26

我想在多个框架内调整窗口大小

但由于框架的原因,它不起作用。

示例(框架.html

<html>
  <frameset cols="15%,*">
   <frame src="a.html" name = "a"> 
    <frame src="b.html" name="b"> 
   </frameset> 
 </HTML>

乙.html

<html>
  <script>
        function temp(){
         document.href.location = "c.html";
        }
   </script>
   <body>
    b
    <input type = button onclick = temp()>
   </body>
   </HTML>

c.html

<html>
<script type = "text/javascript">
     window.onload = function(){
     window.resizeTo(300,300);
     }
 </script>
 <body>
 c
</body>
</HTML>

如果我转到页面 C,我想调整窗口大小,但由于框架而无法正常工作。所以,我使用的目标就像 top.location.href = "url"但它忽略了a.html.我该如何解决问题?

如果要

调整最外层窗口的大小,则不要window.resizeTo(300,300); top.window.resizeTo(300,300);。浏览器窗口是否真的要调整大小取决于浏览器的用户设置。

如果要调整框架的大小,则必须更改相应frameset的属性/属性cols值。

另请注意,document.href.locationdocument.location.href