DotNetDeveloper
DotNetDeveloper

Reputation: 587

Open link in new window using javascript?

i tried below javascript and it does open the url in open window but it clears the url in the current window as well points to the new URL.

window.open('http://www.google.com','_blank');

Upvotes: 1

Views: 4667

Answers (1)

Bill Blankenship
Bill Blankenship

Reputation: 3366

This is occurring because the second spot where you have _blank is where the name should be.

I would recommend as the link above that Nathan post suggests doing this. :

window.open(url, windowName, "height=200,width=200");

Then doing some javascript triggering on whatever event is causing the new window to open.

So, lets say it is an image, set the Target="_blank" for the image and then set an OnClick event to call a function with the window.open code in it.

That will do the trick. HTH

Upvotes: 2

Related Questions