How to click a link using javascript and launch a new window (skipping popup blocker)

Hi All,

I have a link in my page which is targeted to an external URL with an extended attribute (Target = "_blank")

1) When a user clicks the link, safari browser opens a new tab and didn't display any popup blocker in the browser

2) When I try to click the same link using a javascript in my action, safari browser treats it as a popup and Im getting a notification in the browser to click and allow the tab to load. 

How can I make (2) to work similar to (1), I dont want the new tab to be blocked by the browser as a popup.

Thanks,

Karthik J

Hi Karthik,

The whole idea of a pop-up blocker is that it detects automated (i.e. JavaScript-triggered) invocations of opening a link in a new window or tab. You cannot circumvent that, as that would defeat its purpose.

Note that as far as your browser is concerned, there's no difference between a new window or a new tab, that's just a browser setting.

Hi Karthik,


You can try use the following code:

$('#"+YourButtonID+"').click(function () {
    var redirectWindow = window.open('http://google.com', '_blank');
    redirectWindow.location;
});

Fiddle1 Fiddle2 (Using Ajax)

Its worked for me.

Regards