Link to home
Start Free TrialLog in
Avatar of hypervisor

asked on

Always open in new window when using javascript to create a pop-up

I am using the following function to create a pop-up window:

function popitpat(url)
        if (window.focus) {newwindow.focus()}
        return false;

Open in new window

The function works great, however if the user clicks the link multiple times the link re-opens in the window it created originally.  I would like a new pop-up to be created each time the link is clicked.  Any help would be appriciated.
Avatar of Sudhindra A N
Sudhindra A N
Flag of India image

use this..

var wcounter = 1;
			function popitpat(url)
				var wname = 'Name'+wcounter;
				if (Window.focus) {newwindow.focus(); }
				return false;

Open in new window

if the user clicks the link multiple times
Are you saying that you want the url to be open in multiple popup windows if the user clicks the same link mulitple times? Or do you have several different links that you want each opened in a different popup window?

As it is, you are using the variable "newwindow" to reference the popup so each time the link is clicked, the window stored in the variable "newwindow" will be reused to open the link again. If you want multiple popups, you'll need to use multiple variables to reference them (newwindow1, newwindow2, etc.)
Avatar of hypervisor


ansudhindra, the code you posted looks like what I need but I can't get it to work.  Thoughts?
Avatar of experts1

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try adding target=_blank attribute!,'name','target=_blank,height=450,width=1000,scrollbars=yes');

Open in new window

Hope it helps u...