Use SetTimeout In A Function?
Sep 13, 2011
I want to design a page flashes 4 digits when loaded, press submit to stop, and starts when press again.Below is the script:
Code:
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
[code]....
View 1 Replies
ADVERTISEMENT
May 10, 2006
I want to change the elements class name dynamically when mouse is out with respect to that element.I want to change the class name after some delay (i.e, i am using settimeout function).
var ulNodes = getElementsByClass("nice-menu");
var liNodes = null;
for(var i = 0; i < ulNodes.length; i++) {
liNodes = ulNodes[i].getElementsByTagName("li");
for(j = 0; j < liNodes.length; j++) {
if(liNodes[j].className == "menuparent") {
liNodes[j].onmouseout=function(){
timer = window.setTimeout(function (){
this.className = "menuparent"; //My problem is with //this line
},4000);
} } } }
I need to set the elemets class name to "menuparent" after some delay after the pointer moves away form that element.
-> When ever i say alert(this.className); in the setTimeout function, the alert box says undefined.
-> I can succesfully alert any where else in the mouseout function except within the settimeout function in mouseover function of that element.
View 1 Replies
View Related
Oct 10, 2006
I'm not exactly sure why this doesn't work. I'm basically just trying a
simple approach at a slide down div.
function slide_div {
setTimeout("document.getElementById('mydiv').style.length=ཆp x'",1000);
setTimeout("document.getElementById('mydiv').style.length=ཐp x'",1000);
setTimeout("document.getElementById('mydiv').style.length=ཚp x'",1000);
setTimeout("document.getElementById('mydiv').style.length=ཤp x'",1000);
setTimeout("document.getElementById('mydiv').style.length=p x'",1000);
setTimeout("document.getElementById('mydiv').style.length=ླྀp x'",1000);
}
It seems like it just runs the last setTimeout line and pops out all at
once. I've even tried adding a=, b=, c=,. etc at the begining of each
line to no avail.
View 6 Replies
View Related
Mar 7, 2011
How can I have a function parameter in a function?
Something lke setTimeout();
setTimeout(function() {
how can I do it like this?
[code]....
View 4 Replies
View Related
Jul 30, 2009
does anyone know if the setTimeout() function in js has been just recently supported? i created an online demonstration of a product that uses this function to delay the playing of .wav files after various second intervals. i know that Opera doesn't support this function because when I click my button, all of the .wav files that i have in the function that runs behind the button play at once. i have probably 10 wav files that are played throughout the function, at various conditional statements. does anyone know if earlier (like REALLY old) versions of IE do not support this function? or maybe ie8 doesn't support it? i developed this and tested it in all major browsers except IE8 and any version earlier than IE6.
View 5 Replies
View Related
Jun 6, 2009
I did search the forums but couldn't seem to find anything on this specifically. I basically need to pass a key event and a 'name' to nameCheck() after 3 seconds. This works fine in Firefox but Internet Explorer gives the error: Member not found. I'm more of a PHP guy than a JS one
<input type="text" onkeyup="nameCheckTimer(this.value, event)" value="" />
function nameCheckTimer(name, evt) {
setTimeout(function(){return nameCheck(name,evt)}, 3000);
}
function nameCheck(name, evt) {
//need name and the key event to be available here. I have code to handle the key codes which works fine
}
View 6 Replies
View Related
Jan 16, 2010
I am trying to use the window.setTimeout feature so that a message pop-up with yes/no appears on the screen asking whether to extend the session.*If yes is clicked, the current page reloads.*If no is clicked, nothing happens. (the session will expire anyway).
View 5 Replies
View Related
Feb 22, 2011
I have written the following code (quite meaningless. Just to check why setTimeout is not working in a similar real-life code) to enable the user to input a given time interval (hh:mm:ss) when a p is clicked, and then alerting the user with the time entered in the seconds portion one second after the div is clicked. But it is not working. I think the setTimeout is the culprit, the way I am passing parameters to the function inside it, but don't know where exactly am I erring.
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
[Code]....
View 3 Replies
View Related
Oct 31, 2010
I have a button that when you click it displays the results of my db in a div. What I am trying to do is to get the results to update every five seconds.
I thought setTimeout was the best way to achieve this. However I am getting the error message that ID is not defined on the setTimeout line. I thought it would automatically input ID into the fields marked ID when the onloadXMLDocRefres ('File.php','txtHint') button is clicked?
The button works to load the script, but the refreshing the div is not.code...
View 4 Replies
View Related
Feb 2, 2011
I wanted to write my own script for a fade-in animation, since the ones I have found have got too many options or need some framework, which makes them unnecessarily big. I wanted to learn too.Unfortunately, the code didn't work as I wanted, and I commented some things so as to find out what's happening.Why is an object reference assigned to what was previously a string?
View 6 Replies
View Related
Dec 24, 2009
I'm trying to graph line with a delay between each line drawn - my code is:
var jg = new jsGraphics('Canvas');
jg.setColor('maroon');
jg.drawLine(40,130,80,120);
setTimeout('jg.paint()',10000);
jg.drawLine(80,120,120,110);
setTimeout('jg.paint()',10000);
Unfortunately it draws all the lines at the same time i.e the setTimeout function doesn't like the paint method.
View 1 Replies
View Related
Dec 15, 2010
I'm new to JavaScript, and have been playing around with a few simple functions to get going. However, I've hit a problem that I just can't fix, I'm trying to write a simple function to animate the collapse of a div using setTimeout (I know, jQuery does it a lot better), and it's gotten the best of me. The only error it's giving me now is
Code: missing ; before statement on line 25 but I can't see why. I assume it's something to do with my abuse of the setTimeout syntax (why does it insist that everthing is enclosed in quotes.I'm sure there are much better scripts than mine, and searching the forum I've come across Vic Phillips' fine specimen which mostly went over my head. But if I just wanted it to work I'd use jQuery - I'm more interested in why it's not working.
code is below. In addition to this I've also got an external script to compensate for browsers without getElementsByClass, but it should work in modern browsers up to the point where it doesn't!
[Code]...
View 4 Replies
View Related
Jun 24, 2006
I keep getting the function first as being undefined for some reason I
don't get.
I'm trying to use setTimeout() to pause execution so that an image in
my web page is switched every two seconds for another. Code:
View 1 Replies
View Related
Aug 3, 2011
I am using both these functions for the purpose of slider.But when you leave the tab & come again. The slider moves so fast.
Looks like it clears the interval automatically.
View 3 Replies
View Related
Sep 20, 2010
i used setTimeout() function in my image gallery to scroll images , i used setTimeout("myfunction()",1) in my script. Now my image gallery is working properly but problem is that the speed of scrolling images if normal in firefox, but in internet explorer it is slow, and in google chrome it is very fast , Sir how to resolve this problem
[Code]...
View 1 Replies
View Related
Jul 12, 2010
I have the following function that's supposed to say "Please make a guess" 20 seconds after an initial confirmation is displayed. However, it's immediately displayed as soon as someone hits "Cancel". If I change it's time to 40000 (20 seconds after the initial function is called), it does do it 40 seconds total, so it kind of does what I want. So it seems that the second setTimeout is initiated from the time the script is called generally, but I'm looking for a way specifically to have the 20 seconds start only after the "cancel" button is hit.
[code]...
View 1 Replies
View Related
Jul 23, 2005
I'm wondering if its because I don't fully understand setTimeout(). I have a web page that calls a function on the Onload. This function calls two separate functions and then
uses setTimeout() to keep calling itself. Each function randomly generates
a number and then I update the image.src with that.
If I run setTimeout() on just one function by itself, it almost always displays a new pic...but when I put the setTimeout() in the startup function a get a lot of duplicates. I've been watching it for a long time and I don't think it's a coincidence. Any idea
as to why it seems like both functions don't run/update the pic all the time? If I uncomment the line, alert("hello"), it runs all the time? Code:
View 3 Replies
View Related
Jul 1, 2006
i'm working on a small idea and i would like to run this code:-
document.getElementById(id).style.height = origheight+"px";
after a set time period (about 20ms i guess ;) ), however, the following line creates errors:-
var t1 = setTimeout("document.getElementById('+id+').style.height = '+origheight+'px' ",0.5);
any ideas why?
View 6 Replies
View Related
Jul 23, 2005
<img src=http://xxx.com/yyy.jpg
onmouseover="settimeout("document.location='http://www.google.com'"),
2000">
I want to have a 2 seconds delay before it is directed to an URL when the
mouse is over the image.
However, it seems that setTimtOut does not like parameters in the function
part.
View 5 Replies
View Related
Feb 21, 2006
I have a HTML page with a form with 2 buttons like this
....
<input type="button" value="Add" onClick="ClickAdd();"/>
<input type="button" value="Reset" onClick="ClickReset();"/>
....
I also have this javascript code:
----------------------------------------
function ClickAdd() {
setTimeout(test.Add, 100);
//test.Add();
};
function ClickReset() {
setTimeout(test.Add, 100);
//test.Reset();
};
Test = function () {
this.total = 0;
};
Test.prototype.Add = function() {
this.total++;
alert(this);
};
Test.prototype.Reset = function(i) {
this.total = 0;
alert(this);
};
Test.prototype.toString = function() {
return (this.total);
};
test = new Test();
-------------------------------------------
the thing is:
in the ClickAdd function, if i call test.Add() directly, is works ok But if I call it using setTimeout, the /alert(this)/ shows [object Window]....
View 4 Replies
View Related
Mar 11, 2006
Does anyone know whether the ECMA, or an other standard document,
specifies a maximum for the value that can be pass to the setTimeOut()
function in Javascript?
View 28 Replies
View Related
Aug 14, 2006
The below pasted code is my attempt to get the text of a span to change
every second. However, it seems to just set the text of the span to be the last item
in the array. Code:
View 3 Replies
View Related
Apr 3, 2007
I am modifying the suckerfish dropdown code to use settimeout to have
a slight pause before the menus disappear to make it more user
friendly. I have hit a snag with the following statement:
li.
{
timerID=setTimeout('this.getElementsByTagName("UL")
[0].style.display = "none"', timecount);
}
If I put take the statement
this.getElementsByTagName("UL")[0].style.display = "none";
out of the settimeout function, it works. (w/o the pause, obviously).
With the settimeout function, I get "this.getElementByTagName is not a
function" error.
I have tried putting this.getElementsByTagName("UL")[0] is a variable
and then using that in the settimeout function, but then each li will
only open the very last menu in the list. (ie all the menu items open
the last sub menu) Code:
View 4 Replies
View Related
Apr 3, 2007
Can I have two setTimeouts running at the same time - with two
different intervals?
I want to start one timer and, before it times out, start another one
I've tried this and they seems to interfer with one another.
View 7 Replies
View Related
Oct 25, 2007
var SessionTimer;
function StartSessionTimer()
{
SessionTimer = setTimeout('RedirectToSessionTimedOutPage(),60000)
}
function RestartSessionTimer()
{
clearTimeout(SessionTimer);
StartSessionTimer();
}
function RedirectToSessionTimedOutPage()
{
window.location = '/SessionTimedOut.html'
}
When I load the page and call StartSessionTimer(), I know it works because the page redirects after ten minutes (the value of 60000). However, in certain situations I need to be able to call back to the server with AJAX and then have the timer reset - that's when I call the RestartSessionTimer() function. When I do this, for some reason the ten minute window does not get reset.
To troubleshoot, if I remove the second line in the RestartSessionTimer() function the redirect is getting blocked (as planned). However, when I put the second line back in, the page just redirects as originally called - the SessionTimeout value is never
reset properly.
The code above looks good to me, but for some reason the SessionTimeout var does not get reset in the RestartSessionTimer function; it retains its original value?
View 2 Replies
View Related
Jul 20, 2005
I have a pop-up menu; one of those where you scroll over the menu, and
a submenu pops up beneath it. Everything's running smoothly on every
browser I've tested with, except for one problem on every browser: the
"clearing" of the menu.
The menu itself is being called by:
onMouseOver="menu(1)" onMouseOut="clearIt()"
function menu(x) let's "x" refer to a predefined array, which
determines which menu to pop up. That menu is stored in a variable,
showMenu. If x==0, then it changes showMenu to a whitespace, thus
"clearing" the submenu altogether.
clearIt() is a simple function, pasted here:
function clearIt() { setTimeout("menu(Ɔ')", 7000) }
The idea is that the menu will disappear after 7 seconds. The problem
I'm having, though, is that the 7 seconds starts after the first
onMouseOut, and doesn't restart when the visitor mouses over the
second button. So, if I look at the first submenu for 6 seconds, then
when I go to the second button the menu only stays open for 1 second,
instead of starting the timer over.
View 1 Replies
View Related