简体   繁体   English

使JavaScript窗口在所有现代浏览器中居中,而无需额外的功能

[英]Center a JavaScript window in all modern browsers without extra functions

I have a problem in getting a JavaScript window centred in Google Chrome, I have found a solution HERE but it's creating a new JavaScript function that calls the Window.Open . 我在将JavaScript窗口置于Google Chrome中居中时遇到问题,在这里找到了解决方案,但它正在创建一个新的JavaScript函数,该函数调用Window.Open

How to do get it centred in all browsers using Window.Open Only? 如何使用Window.Open Only将其集中在所有浏览器中?

<asp:ImageButton runat="server" ID="imgNew"  onclientclick="window.open('http://www.google.com','_blank','channelmode =1,scrollbars=1,status=0,titlebar=0,toolbar=0,resizable=0,width=400,height:300');" />

For fixed Width and height Try: 对于固定的宽度和高度,请尝试:

window.open('http://www.google.com','_blank', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+400+', height='+300+', top='+ Number((screen.height/2)-(300/2)) +', left='+  Number((screen.width/2)-(400/2)) );return false;

On ImageButton with a disabled Postback: 在禁用了回发的ImageButton上:

<asp:ImageButton runat="server" ID="imgNew" onclientclick="window.open('http://www.google.com','_blank', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+400+', height='+300+', top='+ Number((screen.height/2)-(300/2)) +', left='+  Number((screen.width/2)-(400/2)) );return false;" PostBackUrl="javascript:void(0);" />

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

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