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

4
  • What browser are you using? Have you tried it with other browsers? Commented Jun 28, 2012 at 22:06
  • 1
    Take a look at this thread: stackoverflow.com/questions/726761/… Commented Jun 28, 2012 at 22:06
  • I think it's in the rest of your code. Not this little guy. :) Commented Jun 28, 2012 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() Commented Jun 28, 2012 at 22:22

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.