简体   繁体   中英

Pop up window needs centering on screen

I have this table down the side of this form I'm working on that has hyperlink buttons. The button are for FAQ. What I'm trying to do is when the hyperlink button is clicked I want a small text box, empty browser, whatever may be the simplest approach. I have the page launching with my text in it but it opens up on the left hand corner of my screen.

Here's what I have for code:

<asp:LinkButton ID="lnkBttnPsswrdReset" runat="server" OnClientClick="openPopUp()">Password Reset Info</asp:LinkButton><br />

<%--function to open pop up window for password reset hyperlink button --%>
<script type="text/javascript">
    function openPopUp() {
        myWindow = window.open('', '', 'width=250,height=250')
        myWindow.document.write("<p>Please contact the operator to reset yopur password after IT department business hours</p>")
        myWindow
        myWindow.focus()
    }
</script>

your question look similar to previous question such as the following link.

Center a popup window on screen?

accepted answer copied and pasted below

try this:

function popupwindow(url, title, w, h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no,      menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 

二手的Ajax comboBox .....效果很好

我会建议您使用AlertifyJs之类的东西 ,它比讨厌的Popup在各个方面都更好。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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