This is a discussion on ""setTimeout" function won't work" within the JavaScript Forum section. This forum, and the thread ""setTimeout" function won't work are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
"setTimeout" function won't work
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
"setTimeout" function won't work
Hey programmers!!
I'm having big trouble trying to figure this one out. I have a page with a "Print All" button, but only one frame is showed at the time. The idea is to redirect the frame in order to get the next page, well, that part is already done, but I need to wait till the last page is printed so I can call the next one, therefore I use setTimeout function, but nothing happens. The excecution won't pause and I only get to print one page, besides the errors I get from redirecting so fast the frame. Well I'll leave my script, hoping somebody might help. Thanks... while(parseInt(lastprinted)<parseInt(lastnumber)){ var frame=fraAux; //fraAux is the frame I'm using lastprinted=fraAux.document.forms[0].hdnPag.value;// page counter var s="Printing Page"+frame.document.forms[0].hdnPag.value+". Wait untill page is fully printed, then hit ''Ok''"; fraAux.location.href ="frmCodResult.aspx?Value="+sValue+"&Since="+sSinc e+"&Untill="+lastnumber+"&Begin="+(parseInt(lastpr inted)+1); //redirects the frame and loads next page factory.printing.print(false,frame); //send to printer without prompting setTimeout('',10000); //this doesn't work alert(s);// send an alert, so it'd "manually" wait } |
|
|
|
|||
|
Re: "setTimeout" function won't work
You can't use setTimeout() the way you are trying to use it. It's not a delay loop like the delay() function you get in some languages. You need to give it something to do. This goes where you have the '' in your code. You can enter JavaScript directly in there or direct it to a function. What you are effectively saying is; 'after the specified time delay - do this'. |
|
|||
|
Re: "setTimeout" function won't work
Thanks. Now I get it, setTimeout doesn't pause the excecution, it just does something at a certain time, and the rest goes on.
I solved the problem by using setInterval instead, that way I forget about the while loop. |
![]() |
| Tags |
| quotsettimeoutquot, function, wont, work |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a "tag" system to find relevant "related" pages | MrQuestions | PHP Forum | 3 | Mar 20th, 2008 23:06 |
| [SOLVED] Show "Image" Depends On User "Status"? | Monie | Classic ASP | 6 | Oct 16th, 2007 01:22 |
| ? IS "meta name="robots" content="?" necessary in pages ? | Love2Java | Starting Out | 6 | Aug 8th, 2007 13:48 |
| window.opener.document["nameForm"].getElementById("someid").value; doesnt work | drpompeii | JavaScript Forum | 0 | Feb 17th, 2007 23:09 |
| <option value="yes" class="x"> problem in Firefox | mameha1977 | Web Page Design | 1 | Jun 21st, 2006 11:20 |