function calc(value, rate)
{
setTimeout("calc(value, rate)", 1000);
}
In FireFox error console it says that "value" and "rate" are not defined. But they are?
I've started testing on Win XP SP2 and it now has something called local machine lockdown activated by default. It means that active content, such as JavaScript, is prevented from running.
I thought that the solution was simply - to enable the testing of files locally - to just add what M$ calls the "mark of the web". So I added this line to the tops of my HTML pages: <!-- saved from url=(0013)about:internet -->
However, the local links in the files, such as to external JavaScript files, do not work because (I believe) the HTML files are now treated as an internet zone and not a local zone file.
Without deactivating the lockdown is there a way to get a bunch of inter-linked files to work locally, or is it just my lack of understanding of what's going on that's at fault?
I have done something that works perfectly in IE, but doesn't work at all in Netscape.
I have a page of thumbnail images (Page A). When each thumbnail is clicked on, a small 300x 300 pop up (Page B) appears with a larger "preview." The preview image that appears in the small pop-up is dynamically created with the onClick/ image swapping method. (In other words, when a user clicks on a thumbnail on Page A, it swaps a transparent gif I have placed on Page B with the preview image).
Now I've tested this on IE and it works perfectly. But in Netscape, not only does the image swap not occur (no preview image appears), but the height and width attributes I've designated for the pop up are ignored (the pop up is full screen instead of 300x300).
and what I want to end up is with an array with the sum of the [0], [1] and [2] values, so for instance with this example, I want an array returned like this:
[50, 60, 52] i.e. this is [(32+8+10), (13+17+30), (26+4+22)]
My real problem with this is that the "inner array" can be any number of (its dynamic), so in my example its just 3 values but it could be for example 5 values e.g.:
If I type http://domain.com/product/5 into my browser I will see the product details in the main div plus a side bar div containing links to other products. This side bar is common to all product views. I click a sidebar link to product 6 and an ajax request updates the main cell with the product 6 information. My location bar will still say /product/5. If I refresh the browser I will see product 5. If I bookmark the page it will be for product 5. If I click the back button I will go to the page I saw before product 5. I know none of these problems with AJAX are new. Why is it that JavaScript can't tell the browser "Now you are looking at http://domain.com/product/6"? Is there a security risk? Is this just something not yet implemented?
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.
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:
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);
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?
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:
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:
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:
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?
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.
I have a window up whose Javascript implementation checks for a cookie with code something like this:
function lookieCookie() { alert(document.cookie); setTimeout(lookieCookie, 10000); }
The first call to lookieCookie is in the onload event handler. The cookie is actually set by a PHP routine that is in another script. The PHP script certainly appears to be setting the cookie. The alerts from lookieCookie are clearely happening at the appropriate time intervals (I can't get into the room with the actual code at the moment, so if I have messed up the syntax here, I know that it is not messed up in the real code), but the cookie being set from PHP does not show up.
Obviously the PHP might be doing the wrong thing. In tha case I have to get on the guy that writes the PHP script. Should the code I wrote work even if the cookie is set after the page has loaded, but between iterations of lookieCookie()? If yes, then I must get on the PHP coder and get his page fixed.
I have an image that when hovered, another image pops up (this popup image has a 'learn more' button on it), but when someone attempts to mouse over the button, the image restores to its original image. I was advised to use 'setTimeout' but do not know how to apply it with the following code...
I understand WHY it's going back to its original state (the mouse is hovering outside of the area coordinates), but how can I apply the setTimeout script to DELAY the image from going back to its original state?
I'm trying to build the framework for an AJAX back/forward button fixer. Basically it uses the hash fix for them (using text after the # to add history objects). To this effect, the function to check for updates has to be run every second or so. No problem, I'll just use setInterval for that.
For whatever reason, though, setInterval gives me an error. Specifically that oldLocation (global variable) is undefined (in the checkURL function). So I try setTimeout. Same thing. When I just call the function explicitly once (adding checkURL(); to the end of the script) everything works wonderfuly; it's just setting it up on a timer that messes up. Frankly, I've no idea why it's doing this. (The bug just seems so odd) Maybe a more advanced JS coder can shed some light on it.. Code:
I know sometimes javascript and php can be used together. Anyone know how to add a javascript set timeout to this? So that this php include will re-execute after so much time? Or is there a php refresh command I can add to this code itself, not the page.
Basically on the load of a page I am making an ajax call that returns a string with integers seperated by commas. I have verified that the returns from the ajax call are working correctly, but then I am trying to take that string, break it into an array, and use the values in that array to use setTimeout and call the function at those intervals.
//Create our array outside of a function so it's available var wait_time = new Array();
//function that handles the ajax return function process_wait_time_return(str) { wait_time = str.responseText.split(','); update_current_show(0, wait_time); }
//Function that changes the div html with new information function update_current_show(array_index, wait_time) { $("currently_playing").innerHTML = array_index; var next_index = array_index + 1; setTimeout('update_current_show(next_index, wait_time)', 3); }
This is on a test page, so for testing purposes I'm just updating the div with the current array index to verify it's cycling through the array, which it's not.
<script language="javascript"> <!-- function reloadOpener(){ setTimeout(doItNow,2000); } function doItNow(){ window.opener.location.reload(); } //--> </script> And there's a button in the body that says:
onClick="reloadOpener();"
When I try it without the setTimeout function, the opener page reloads no problem. I just need it to wait a wee minute, but when the setTimeout is there, nothing happens. Ever.
For the sake of completeness I have tried it with: