Jump to content

Recommended Posts

Here's what i'm trying to do. Basically i want to use javascript to check if the user has clicked the mouse button onto a specific link withing a certain amount of time.

 

To make the above clearer i'll give you the scenario... my page loads and only a linked image shows up. While to me it's clearly obvious to think... ok the only thing on the page, let's click it. To others it may not be so obvious, so i want to create an action if a user does not click on the linked image withing let's say 15 seconds after the page has been loaded.

 

Is that possible, if so... what function(s) could i use to achieve this.

 

Thanks to all who help.

 

Ok i figured it out...

 

Here's how for the curious ones.

 

I started a counter, so for ever 1 second i increased the variable C by 1.

 

var c=0;

var t;

 

function timedCount()

{

if(c == 5)

{

$('#reminder').delay(100).fadeIn('slow');

$('#reminder').delay(100).fadeOut('slow');

return;

}

c=c+1;

t=setTimeout("timedCount()",1000);

}

 

at 5 seconds something happens, and to stop it.. onClick the image clears the time counter with clearTimeout(t); effectively stopping the function's if statement from ever occuring as long as it's before the 5 second mark.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.