![](/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.