This is a discussion on "I thought I had found just what I was looking for when" within the JavaScript Forum section. This forum, and the thread "I thought I had found just what I was looking for when are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
I thought I had found just what I was looking for when
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
I thought I had found just what I was looking for when
I have been trying to find a a JavaScript function that will repeatedly run my change image function and when I found a site that gave it to me I thought I had the answer. My own writing of a recursive function kept failing so the comments in code below seemed like the answer I was looking for. However I think I've been following the instructions faithfully but it doesn't work. Below is a quote in a code snippet which can be found at this link http://songhaysystem.com/document.ph...&code=htmlscrp. It is followed by my experimental use of this code snippet which should write the numbers 1 through 10 one line at a time. Firefox will only render the number 1 from my code. The Firefox JavaScript console gives me the following error messages in warnings.
"Warning: assignment to undeclared variable timeoutID Source File: file:///c:/htmlplay2/pro1LeadImage/whyIwasLookingFor.htm Line: 15" Also this error message. "Error: MyFunc is not defined Source File: file:///c:/htmlplay2/pro1LeadImage/whyIwasLookingFor.htm Line: 15" I would appreciate it very much if somebody could help me get this code going. Below is all that I have mentioned above. " Many designs using a for or while loop structure may instead have needed the setTimeout() method of the window object calling a function recursively. The general form of this structure is: function MyFunc() { //code here timeoutID = setTimeout("MyFunc()", 1000) } where timeoutID is a script-global variable. After MyFunc() is called, this structure then recursively calls MyFunc() every second until clearTimeout(timeoutID) is used. Unlike a for or while loop, this "loop" is time based." My code. <head> <title></title> <script language="JavaScript"> <!-- var c=0; var timeoutID=0; function MyFunc() { c += 1; window.document.write(c + "</br>"); timeoutID = setTimeout("MyFunc()", 1000); } --> </script> </head> <body onload="MyFunc()"> </body> </html> |
|
|
|
||||
|
The problem comes when writing to the document stream directly... this however will work if you do it a slightly different way:
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
![]() |
| Tags |
| thought, had, found, was |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hi thought I'd introduce myself | Ducky | Introduce Yourself | 7 | Feb 29th, 2008 21:51 |
| thought of suggestion | alexgeek | Webforumz Suggestions and Feedback | 7 | Sep 22nd, 2007 14:15 |
| Just A Thought | JacobHaug | Webforumz Cafe | 6 | Dec 4th, 2006 23:31 |
| Thought I'd say hello....... | caseysmom | Introduce Yourself | 7 | Mar 18th, 2005 22:52 |