Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

body onload function problem

Status
Not open for further replies.

zubz

Programmer
Mar 29, 2005
14
GB
I have a page called test.cfm which has a body onload function like so. basically the function redirects back to the same page. This works but the function sems to get called continiously. I though that the page only gets loaded once hence the funtion is called only once. But this does not seem to be the case. Can anyone please help? Thanks

function locate() {
window.location.href='test.cfm?appid=12&refresh=yes';
}



<body onLoad="return preRelocate();"></body>
 
basically the function redirects back to the same page.

At which time the page reloads itself, and calls the function again.

Surely you can see what's going on here.

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
And after that, the page reloads itself, and calls the function again :)

Cheers,
Dian
 
duh! of course. is there a way to only call this function only once
 
I think the more important question is why does the page need to reload right after it's already done so?

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Or just call to another page with the same code except the onLoad part, but that still doesn't answer kaht's question: why?

Cheers,
Dian
 
You are using cold fusion server-side... so you can decide to output the onload event server-side. Maybe you can set a session variable or something - and if the session variable is not set, output the onload code; if it is set, then do not output the onload code.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top