onLoad event handler

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
jonat8
Forum Newbie
Posts: 15
Joined: Sat Oct 12, 2002 1:02 pm

onLoad event handler

Post by jonat8 »

Hi,

I'm trying to get Javascript to execute a function when the page finishes loading:
<body background="exptextb.jpg" onLoad="javascript:pM">
and directly below that is the function:
<SCRIPT LANGUAGE=JavaScript>


function pM {
WindowsMediaPlayer.FileName = "/mediabase/" + <?php echo $tracktoplay ?>;
}

</SCRIPT>
But for some reason that doesn't seem to work, I just get the error in IE that "pM is undefined". It looks okay to me, or is there something I'm missing?! I've tried just putting ..."onLoad="pM"... instead of javascript:pM but it still doesn't work.

TIA for any help
jonat8
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

<SCRIPT LANGUAGE=JavaScript>
	function pM() &#123;
		WindowsMediaPlayer.FileName = "/mediabase/" + <?php echo $tracktoplay ?>;
	&#125;
</SCRIPT>
...
<body background="exptextb.jpg" onLoad="javascript:pM();">
...
Post Reply