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

vicR
  • 789
  • 4
  • 23
  • 52

2 Answers2

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>
Anup Singh
  • 1,513
  • 3
  • 16
  • 32
0

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

Arjun Sol
  • 731
  • 5
  • 18