This topic is locked

Running a javascript on page load

10/24/2007 7:23:39 PM
PHPRunner General questions
G
giles author

Hi,

I want a javascript function to always run when a page is first displayed. To date I have put <script> myfunction() <\script> in the page using Visual Editor.
That works but requires a modification of the page.
Can the javascript function call be placed in an event? And if so, what's the call look like?
Giles
P.S. Thanks to the phprunner folks for quick responses to all my previous questions. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=6613&image=1&table=forumtopics' class='bbc_emoticon' alt=':D' /> Your support has been excellent. (I try not to say thanks for each individual question 'cause that's another post everyone ends up reading.)

A
alang 10/24/2007

Just use an echo statement in your event code (onLoad possibly) - eg:
if($_SESSION["message"])

echo "<script language=javascript>alert('".$_SESSION["message"]."')</script>";
I use this sort of code in the footer.php