Because when the cfml engine parses this line, it enters a static date
into the javascript, so it ends up being this:
function runMe() {
parent.showDate.document.write("blah blah");
}
So if you want the date to change, you have to either use a JavaScript
date object or you have to have it refresh the page...
Put this in a separate cfm template and load it into your frame
instead:
<body onload="window.setTimeout('location.reload()',2000);">
<cfoutput>#now()#</cfoutput>
<body>
Much simpler...
> You guys are great...here's another one...lol:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
> Transitional//EN">
> <html>
> <head>
> <title>Testing</title>
> <script language="JavaScript">
> function runMe(){
> parent.showDate.document.write("<cfoutput>#now()#</cfout
> put><br>");
> testingThis();
> }
> function testingThis(){
> setTimeout('runMe()',2000);
> }
> </script>
> </head>
> <body onload="runMe();">
> <table border="0">
> <tr>
> <td>
> <iframe src="frameDisp.cfm"
> name="showDate"
> id= ""
> width="300"
> height="300"
> marginwidth="2"
> marginheight="2"
> align="middle"
> frameborder="1"
> class="">
> Your browser does not support in-line frames!
> </iframe>
> </td>
> </tr>
> </table>
> </body>
> </html>
> I no longer have the object expected error, but besides
> the rewriting of
> the Date, It's writing the same instance of the Date.
> Why?
> Ron
> -----Original Message-----
> From: Nate Nielsen [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 01, 2003 10:03 AM
> To: [EMAIL PROTECTED]
> Subject: RE: CF and Javascript
> 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()',1
> 000);
> }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 onload="testingThis();">
> </body>
> </html>
> ----------------------------------------------------------
> -----
> It runs once and then after 2 seconds I get the error.
> Ron Mast
> Truth Hardware
> Webmaster
s. isaac dealey 972-490-6624
team macromedia volunteer http://www.macromedia.com/go/team
chief architect, tapestry cms http://products.turnkey.to
onTap is open source http://www.turnkey.to/ontap
-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To unsubscribe:
Send UNSUBSCRIBE to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org