繁体   English   中英

如何在页面加载时在单独的全屏窗口中打开网页?

[英]How to open the webpage in a separate full screen window on page load?

我正在尝试在页面加载时在全屏窗口中打开网页(就像大多数银行网站一样)。 我可以通过单击链接来做到这一点,但是当我将其保留在onload函数中时,它将陷入无限循环。

以下是我所做的

<html>
<body>
<ul>
<li><a class="sprite_stumbleupon" href="#"  onclick="return windowpop()">Link</a>
</li>
</ul>

<script>
 function windowpop() {
 var leftPosition, topPosition;
 //Allow for borders.
 leftPosition =  10;
 //Allow for title and status bars.
 topPosition = 50;

 //Open the window.
 window.open(window.location.href, "Window2", "status=no,height=" + 
 screen.height + ",width=" + screen.width + ",resizable=yes,left=" + 
 leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",
 screenY=" +    topPosition +",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
 }

 </script>

 </body>
 </html>

当我单击URL时,上面的代码工作正常。 我想要的是在加载页面时执行相同的功能,因此我在body标签内的onload中调用了windowpop()函数。 然后继续加载新窗口。 没有关于如何只加载一次新窗口的线索。 高度重视任何帮助。 提前致谢。

似乎您在将调整大小后的窗口的名称声明为Window2 也许您可以利用它来发挥自己的优势并添加一条if语句:

if(window.name != 'Window2'){
    window.open(...);
}else{
    alert("This is fullscreen!");
}

那应该只在全屏模式下打开一次窗口。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM