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
-
And if I said "works for me"?lc.– lc.2013年09月13日 08:18:25 +00:00Commented Sep 13, 2013 at 8:18
-
possible duplicate of Open url in new tab using javascriptQuentin– Quentin2013年09月13日 08:22:49 +00:00Commented Sep 13, 2013 at 8:22
2 Answers 2
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
Anup Singh
1,5633 gold badges16 silver badges32 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Unfortunately this cannot be controlled, it's entirely at the discretion of the user-agent.
Comments
default