Devotee007

Delay clickTag

Recommended Posts

Hi,

 

A client wants to delay the time before the click on the clickTag happen. A short message is to be shown before the new tab/popup opens. But when I put the clickTag in a setTImeout all browsers gives me warnings about a popup window. I have set my browsers to open tab instead of popup. If I take away the setTimeout it works as it should, there is a short delay and then the tab opens with the correct link. What can this be, I can't see anything wrong with the setTimeout? 


 

function clickTagUrl() {
setTimeout(function() {
 window.open(window.clickTag, "_blank")
}, 800);
}

 

//Devotee007
       

Share this post


Link to post
Share on other sites

Hi @Devotee007. We really try to keep these forums focused on GSAP-specific questions. I wish we had the time and resource to offer free help for general web development issues too. 

 

I believe that the issue you're running into has to do with some security restrictions in the browser and that they want to be very careful about allowing JavaScript to spawn new windows, so they typically only allow it on direct user interaction (like a click event). If I remember correctly, the event object passed along to event listeners has a property like isTrusted or something like that which is read-only and indicates if it's truly user-initiated. I bet there's some sort of time limit as well, so you can't just hang onto that event and use it later to "fake" a user interaction. 

 

In my opinion, you may need to tell your client that it's a dangerous thing to implement some sort of delay between the user's click and the resulting new window/tab. As a user, I know I can't stand it when web sites do that to me (suddenly try spawning new windows/tabs when I didn't even do anything). Ultimately it can taint the perception of the brand or experience. Just my opinion, though. 

 

Good luck!

  • Like 2

Share this post


Link to post
Share on other sites

Thank you all, I got the client to NOT go with this solotion. :) And to Greensock, sorry for posting this question here in the first place.

 

//Devotee007

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.