按钮上的弹出窗口单击...... [英] PopUp window on Button Click ......

查看:83
本文介绍了按钮上的弹出窗口单击......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码打开aspx页面作为弹出窗口.

I am using following code to open a aspx page as popup.

btnSearch.Attributes.Add("onclick", "Javascript:var PopUpWin = window.open('SearchPR.aspx','_blank','width=600,height=380,title=yes,toolbar=no,location=no,resizable=no,status=no');return false;")


我的问题是,如果弹出窗口已经打开,我不想再次打开它.现在,如果弹出窗口已经打开,我再次单击btn,它将打开另一个弹出窗口.

我该如何解决?


My issue is if the popup window is already open, i dont want to open it again. Right now, if popup is already open, and i click the btn again, it open another popup window.

How do I fix this?

推荐答案

将"window.open"替换为"window.showModalDialog"

有关详细信息,请导航

如果您还有其他疑问,请告诉我.
replace "window.open" by "window.showModalDialog"

For detail please navigate

If you have more concerns, please let me know.


以下脚本可能有用-

The below script might be useful -

<script language="JavaScript"><!--
var windowHandle = null;
var windowHandle_closed = false;

function openWindow() {
    windowHandle = window.open(''SearchPR.aspx'',''_blank'',''width=600,height=380,title=yes,toolbar=no,location=no,resizable=no,status=no'');
    if (windowHandle_closed) {
        windowHandle_closed = false;
    }
}

function closeWindow() {
    if (windowHandle != null) {
        if (!windowHandle_closed) {
            windowHandle_closed = true;
            windowHandle.close();
        }
    }
}
//--></script>





HTH
拉杰夫


如果有帮助,请投票并标记答案为可接受





HTH
Rajeev


Please vote and mark the answer as accepted if this helps


为新窗口提供相同的名称,它将始终在同一窗口中打开.

现在,对于新窗口,在所有情况下都必须使用其他名称.这迫使人们在不同的领域而不是仅在现有的领域打开.

例如:"myWindowName"是始终需要相同的名称.
Give same name to the new windows and it will open in the same window all the time.

Right now, you must be using different name in all the cases for the new window. This forces to open in the different one and not in the existing one only.

For ex: ''myWindowName'' is the name that needs to be same all the time.
var reportWindow = window.open('CostByProject.aspx', 'myWindowName','height=650,width=900,resizable=1,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no');



在此处阅读详细信息: MSDN:Window.Open() [ ^ ]

附注:"_ blank"将始终触发新窗口.将其替换为固定名称即可.



Read the details here: MSDN: Window.Open()[^]

P.S.: "_blank" will always trigger a new window. Replace it with a fixed name and you will be set.


这篇关于按钮上的弹出窗口单击......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆