Multiple Popups With One Click like kayak Javascript

I has to develop for a client a function to open multiple popups of information in just one click.

I create a function like this:

<script>
var index = 0 ;
function openWindows()
{
    var url = new Array() ;
    url[0] = "http://www.marca.com" ;
    url[1] = "http://www.google.es" ;
    for(i=0; i < url.length ; i++)
    {
        window.open(url[index],"ident_"+index) ;
        index = index + 1 ;
    }
    index = 0 ;
}
</script>

I call this function with the next code

<a href="javascript:openWindows()">Open Popups</a>

This function runs perfectly on Firefox, but on Chrome and Internet Explorer i get the second popup blocked ( the first one opens perfectly )

I dont know how to do it.At first, i thought that it was not possible, but then, i see a website ( http://www.kayak.es/ ) where you choose how many sites do u want to compare with kayak and he opens all the selected sites in Popups with one click.

Someone knows how to do it?

Upvotes: 1

Views: 818

Answers (2)

user2342558
user2342558

Reputation: 6737

Try passing to the second popup a parameter to tell him to open the next popup and so on. Maybe the browser check to opener window to block multiple popups. Or try to put some microtime-sleep between each opening.

Upvotes: 0

Anton Igonin
Anton Igonin

Reputation: 283

The code is correct. Try to check your security settings in Chrome and IE, they are blocking multiple popups in some way.

Upvotes: 1

Related Questions