Title: Message

Heheh

 

This is a clever little problem. 

 

Here is what is happening. 

 

Page loads, calls testingThis()

In 2 seconds, it calls runMe()

It uses the document.write() function

This clears all data on the page, including the script you are trying to run.

 

Object not found.  You need to do something other than write to the page that is running the script.  Usually if you want to use document.open() or document.write() you write to a different frame.  top.frameName.document.write()  . . etc.

 

–You can have multiple setTimeout() statements on a page, even if it creates an infinite loop, as long as there is enough time between iterations for other processes to run – it won’t lock up the browser.  This is how those little _javascript_ timers and clocks are created!   =)

 

ex:

var countdown = 5;

function liftoffCountdown(){

            if(countdown <= 0){

                        alert(countdown);

countdown--;

                        setTimeout(‘liftoffCountdown()’,1000);

            }else{

                        alert(‘liftoff!’)

            }

}

liftoffCountdown();

 

 

this would alert ‘5’ ‘4’ ‘3’ ‘2’ ‘1’ ‘liftoff!’.   You could change the countdown to 500000 and it wouldn’t lock the browser (just make sure you can close the browser in that 1 second gap between alerts!   Lol.  (just an example people)

 

Best Regards,

 

Nate Nielsen

[EMAIL PROTECTED]

 

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dan Blackman
Sent: Wednesday, October 01, 2003 9:08 AM
To: [EMAIL PROTECTED]
Subject: RE: CF and _javascript_

 

Looks like SetTimeout Can only run once on a page...I took out the SetTimeOut and it creates an infinite loop.  Not sure the purpose of creating this loop, but SetTimeout running multiple times is your issue.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ron Mast
Sent: Wednesday, October 01, 2003 8:37 AM
To: [EMAIL PROTECTED]
Subject: CF and _javascript_

Hello,
Can someone tell me why I'm getting an object expected error when I run the following:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
        <title>Testing</title>         
       
<script language="_javascript_">
        function runMe(){
                document.write("<cfoutput>#now()#</cfoutput>");
                testingThis();
        }
        function testingThis(){
                setTimeout('runMe()',2000);
        }
</script>      
       
</head>

<body >

</body>
</html>

---------------------------------------------------------------

It runs once and then after 2 seconds I get the error.

Ron Mast
Truth Hardware
Webmaster

Reply via email to