1

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');

DotNetDeveloper
  • 587
  • 2
  • 9
  • 19
  • What browser are you using? Have you tried it with other browsers? – Jeremy Rodi Jun 28 '12 at 22:06
  • 1
    Take a look at this thread: http://stackoverflow.com/questions/726761/javascript-open-in-a-new-window-not-tab – Sturm Jun 28 '12 at 22:06
  • I think it's in the rest of your code. Not this little guy. :) – TNC Jun 28 '12 at 22:09
  • 1
    Is window.open() being called from a click event? If so, you'd have to stop the event from bubbling/propagating (which would cause the main browser window to point to the new url as well). Using jquery, event.preventDefault() – Alex Heyd Jun 28 '12 at 22:22

1 Answers1

2

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

Bill Blankenship
  • 3,316
  • 6
  • 43
  • 73
  • Thank you every one for all the comments and useful information. 1) I added target = _blank attribute via jquery on the ready 2) I added event.PreventDefault() for the OnClick This two things did the trick. – DotNetDeveloper Jun 29 '12 at 15:06