1

What I want to do -

1) On Click of a button I will open a new window(popup).

2) When I click on same button, If the window(popup)is already open I will not open it again instead bring the previously opened window(popup) on top of all windows.

3) If popup is not open I will use window.open() to open a popup.

What I did till now -

1) On Click of a button I will open a new window(popup).

2) Problem : How do I not allow opening of new window on click of button if window is already open?

Aman J
  • 1,825
  • 1
  • 16
  • 30

2 Answers2

1

Here you go:

Javascript function:

<script language="javascript" type="text/javascript">
function popitup(url) {
    newwindow=window.open(url,'name','height=200,width=150');
    if (window.focus) {newwindow.focus()}
    return false;
}
</script>

HTML tag:

<a href="popupex.html" onclick="return popitup('popupex.html')">Link to popup</a>

Source: http://www.quirksmode.org/js/popup.html
Please take a look at the source for this and how they got it to work. They do also have some examples of exactly what you need.

Mark Topper
  • 652
  • 1
  • 8
  • 23
0

Please take window.open() in one variable like

var w= window.open(); It will not open new window again.

Good Luck.

Sid
  • 801
  • 8
  • 19