1

Basically I just want to click on the link an a new window should open. But the window does open in a new tab. Not sure why

<a href="http://www.google.com" target="_blank" style="font-size: 12px;" onclick="popupwindow(this.href, 'Redirect to')"><b>Link</b></a>

The JS: Fiddle link

asked Sep 13, 2013 at 8:16
2
  • And if I said "works for me"? Commented Sep 13, 2013 at 8:18
  • possible duplicate of Open url in new tab using javascript Commented Sep 13, 2013 at 8:22

2 Answers 2

3

Follow Steps :-

1. In html write return false to avoid default event default behaviour
2. From javascript return false
3. Check for popup blocker

JAVASCRIPT

function popupwindow(url) {
 newwindow=window.open(url,'name','height=200,width=150');
 if (newwindow == null || typeof(newwindow)=='undefined') { 
 alert('Please disable your pop-up blocker and click the "Open" link again.'); 
 } 
 else { 
 newwindow.focus();
 }
 return false;
}

HTML

<a href="popupex.html" onclick="return popupwindow(this.href)"
 >Link to popup</a>
answered Sep 13, 2013 at 8:23
Sign up to request clarification or add additional context in comments.

Comments

0

Unfortunately this cannot be controlled, it's entirely at the discretion of the user-agent.

answered Sep 13, 2013 at 8:20

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.