![](/img/trans.png)
[英]How to set the screen height and width by %(percentage) in javascript
[英]Opening javascript popup window without address bar and title with height and width set in percentage according to screen resolution
我想使用没有标题和地址栏的javascript打开弹出窗口,并且还想根据屏幕分辨率设置其高度和宽度百分比。我该如何实现这一点。 我做了这段代码;
function popitup(url) {
LeftPosition = (screen.width) ? (screen.width - 800) / 2 : 0;
TopPosition = (screen.height) ? (screen.height - 700) / 2 : 0;
var sheight = (screen.height) * 0.9;
var swidth = (screen.width) * 0.8;
settings = 'height='+ sheight + ',width='+ swidth + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes,resizable=yes,toolbar=no,status=no,menu=no, directories=no,titlebar=no,location=no,addressbar=no'
newwindow = window.open(url, '', settings);
if (window.focus) { newwindow.focus() }
return false;
}
但是我仍然可以看到地址和标题栏。这是浏览器的相对版本和类型吗?如果是的话,如何在最新版本的浏览器(如IE9,Chrome,Firefox和safari)中实现这些设置?
出于安全原因,这是不可能的。
查看http://www.codeproject.com/Questions/79625/How-to-hide-title-bar-in-Javascript-popup
您可以使用模式对话框等更具吸引力的替代方法。 大多数JS库提供开箱即用或使用插件的模式对话框。
应该是menu = no
还是menubar = no
??
settings = 'width='+w+',height='+h+',top='+top+', left='+left+',menubar=no,resizable=no,scrollbars=yes,location=no,toolbar=no'
对我来说很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.