[RESOLVED]How to open popups on new tab?

Hi All,

I want to open the popups(more than 1 at a time) on new tab.

hdnarrID has ID(s) with comma separated
Ex:"21,34,56"

My Code:

function TNToDownload() {       
        var arrRes=$("#hdnarrID").val();      
        var strResult=arrRes.split(',')
        for(var i = 0; i < strResult.length-1; i++)
{ window.open('/download/sample/'+strResult[i]); } }

Above method get call on button click and it  works fine with IE and Mozilla browser. It fails on Chrome browser.

Thanks in Advanced

Netra S W

It’s my understanding that this is client defined behaviour, i.e. how the user has their browser options set, however this thread seems to suggest a solution you may find works

"window.open must be called within a callback which is triggered by a user action (example onclick) for the page to open in a new tab instead of a window."

http://stackoverflow.com/questions/11999837/force-window-open-to-create-new-tab-in-chrome

Generally, you can use the ‘_blank’ target to indicate that you want to open a window within a new tab :

window.open('/download/sample/'+strResult[i],'_blank'); 

Hi Rion William,

I have tried this too. But the result is only one new tab gets created and rest of all get open as new window.

Thanks,

Netra S W

You might also try using something like a generic new variable instead of "_blank" to see if that makes any difference :

window.open('/download/sample/'+strResult[i],'_blank' + i.ToString());

Leave a Reply