Jump to content

SetTimeout() help


harshpandya

Recommended Posts

I know its pretty easy to use SetTimeout() butsee the code: setTimeout("handlePTZMouseDown", 5000);Everytime i click i need 5 seconds delay before I click again in iframe, Function has to wait for 5 seconds everytime i click or call this function.this is how i am calling this function:document.onmousedown = handlePTZMouseDown;but when i put this it does not work:document.onmousedown = setTimeout("handlePTZMouseDown", 5000);so how should i do this?Help Are you guys available on weekends also so i can ask questions.....?Thanks in advance

Link to comment
Share on other sites

Either pass the function object:

document.onmousedown = setTimeout(handlePTZMouseDown, 5000);

Or pass a string to be eval()'d:

document.onmousedown = setTimeout("handlePTZMouseDown()", 5000);

Most are probably more available on weekends than weekdays because this is a spare-time kind of thing. Even if no one is, you can leave a question to be found whenever the next person visits.

Link to comment
Share on other sites

What exactly are you trying to get to happen?

Everytime i click i need 5 seconds delay before I click again in iframe, Function has to wait for 5 seconds everytime i click or call this function.
What do you mean by that? Are you saying that when someone clicks inside an iframe, you want the entire iframe disabled for the next 5 seconds before they are allowed to click inside it again?
Link to comment
Share on other sites

What exactly are you trying to get to happen?What do you mean by that? Are you saying that when someone clicks inside an iframe, you want the entire iframe disabled for the next 5 seconds before they are allowed to click inside it again?
Thats Exactly i want. is there a way. My iframe mouse down function should be disabled for 5 secondsThanks
Link to comment
Share on other sites

Well, I'm not sure if you can disable an entire iframe. If you can, then you would do it like this:document.getElementById("theiframe").disabled = true;ordocument.getElementById("theiframe").enabled = false;I can't remember if elements have a disabled or enabled property, one of the two.If that doesn't work, then you will need to register an onclick or onmousedown handler with the document inside of the iframe and return false from it if it is less then 5 seconds from the previous click. You can use a variable to hold true/false if it is within 5 seconds from the previous click, and use a timeout like was shown above.

Link to comment
Share on other sites

I have function that detects the click inside the Iframe now.All i wanted to do it whenver i call this function it should wait for 3 seconds. Basically i want to disable my iframe clicks for 3 seconds. After 3 seconds they can click again and wait for 3 more seconds..OR Give me a alert message that waits for 3 seconds and close it self after 3 seconds. Help me on one of this....

Link to comment
Share on other sites

Not certain about the frames aspect of this, but disabling the mouse clicks for 3 seconds is simple enough. Something like this:

<html><body><script type="text/javascript">function click_handler(){	document.onclick = null;	document.getElementById("output").innerHTML += "clicked ";	setTimeout("document.onclick = click_handler;", 3000);}document.onclick = click_handler;</script><div id="output"></div></body></html>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...