Click here to Skip to main content
12,746,850 members (32,240 online)
Rate this:
Please Sign up or sign in to vote.
I am using following code to open a aspx page as popup.
btnSearch.Attributes.Add("onclick", "Javascript:var PopUpWin ='SearchPR.aspx','_blank','width=600,height=380,title=yes,toolbar=no,location=no,resizable=no,status=no');return false;")

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?
Posted 8-Mar-11 11:38am
Updated 8-Mar-11 11:55am
SAKryukov 8-Mar-11 16:53pm
I would suggest you remove all tags except Javascript, they are irrelevant.
This is a valid Question and a very typical issue, so I vote 5.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

replace "" by "window.showModalDialog"

For detail please navigate

If you have more concerns, please let me know.
Rubaba 9-Mar-11 15:06pm
exactly 5.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

The below script might be useful -

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

function openWindow() {
    windowHandle ='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;


Please vote and mark the answer as accepted if this helps

Rate this: bad
Please Sign up or sign in to vote.

Solution 3

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 ='CostByProject.aspx', 'myWindowName','height=650,width=900,resizable=1,status=yes,scrollbars=1,toolbar=no,menubar=no,location=no');

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.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170215.1 | Last Updated 9 Mar 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100