How to show fullscreen popup window in javascript?

此生再无相见时 提交于 2019-11-27 14:22:43

问题


Is there a way to make a popup window maximised as soon as it is opened? If not that, at least make it screen-sized? This:

window.open(src, 'newWin', 'fullscreen="yes"')

apparently only worked for old version of IE.


回答1:


Use screen.availWidth and screen.availHeight to calculate a suitable size for the height and width parameters in window.open()

Although this is likely to be close, it will not be maximised, nor accurate for everyone, especially if all the toolbars are shown.




回答2:


More than bad design - this "feature" is a recipe for UI disaster. There were a number of malicious web sites which exploited the full screen view features in JavaScript to hijack browser windows and display a screen indistinguishable from the user's desktop. While there may still be a way to do this, please for the love of all things decent, do not implement this.




回答3:


What about this:

var popup = window.open(URL);
if (popup == null)
   alert('Please change your popup settings');
else  {
  popup.moveTo(0, 0);
  popup.resizeTo(screen.width, screen.height);
}



回答4:


What about this, I gave width and height value to a big number and it works

window.open("https://www.w3schools.com", "_blank","toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=4000,height=4000");



回答5:


Try this. This works for me and with any link you want, or anything in the popup

Anything you chose will be shown in a PopUp window in a full screen size within a PopUp Window.

<script language="JavaScript">
function Full_W_P(url) {
 params  = 'width='+screen.width;
 params += ', height='+screen.height;
 params += ', top=0, left=0'
 params += ', fullscreen=yes';
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=no';
 params += ', status=no';
 params += ', toolbar=no';


 newwin=window.open(url,'FullWindowAll', params);
 if (window.focus) {newwin.focus()}
 return false;
}
</script>

<input type="button" value="Open as Full Window PopUp" onclick="javascript:Full_W_P('http://www.YourLink.com');"></input>


来源:https://stackoverflow.com/questions/172748/how-to-show-fullscreen-popup-window-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!