Vincent
Vincent

Reputation: 374

Delay window open on click with JQuery

Here is an example page: http://vincent-massaro.com/modal/modaltest.html

I am trying to have a window open with Jquery when a link is clicked, but delay the popup so that a message is first displayed before the popup happens. As you can see from the example the window.open happens not on the click, but on the fade, so this triggers a popup blocker because it is not being triggered by the user click input. Is it possible to move the window.open and delay it so that when the link is clicked, the window.open and the modal message fire off at the same time, but the window.open is delayed 5 seconds so that it doesn't trigger the popup blocker? Thanks!

Upvotes: 1

Views: 2552

Answers (2)

jerone
jerone

Reputation: 16871

Haven't tried it, but put the window.open in a timeout function and bind it separately to the link.

Upvotes: 0

meder omuraliev
meder omuraliev

Reputation: 186562

setTimeout(function() {

// window.open call

}), 5000 );

It won't be an accurate 5 seconds, it depends on how busy the browser is. But accurate enough. Put that in your .click fn.

Upvotes: 2

Related Questions