gpt4 book ai didi

javascript - 弹出窗口需要在屏幕上居中

转载 作者:行者123 更新时间:2023-11-30 17:50:20 25 4
gpt4 key购买 nike

我在我正在处理的带有超链接按钮的表单旁边有这张表。该按钮用于常见问题解答。我想要做的是当单击超链接按钮时我想要一个小文本框,空浏览器,无论是最简单的方法。我启动了包含我的文本的页面,但它在屏幕的左上角打开。

这是我的代码:

<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>

最佳答案

您的问题看起来与之前的问题类似,例如以下链接。

Center a popup window on screen?

已接受的答案已复制并粘贴在下方

试试这个:

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);
}

关于javascript - 弹出窗口需要在屏幕上居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19167303/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com