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

问题描述

我正在使用以下代码打开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?

推荐答案


<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


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.


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

07-18 00:11
查看更多