Page 1 of 1

[SOLVED] Calling a Javascript function

Posted: Wed Feb 02, 2005 6:17 pm
by RayonMazter
Ive seen this question asked tons of times, but for something different.

This cant be done through an event.

i want to execute a java script function when server sends certain info.

But i cant just do the
echo <script>;
echo TheFunction();
echo </script>;

because it keeps adding to their html uhh is it called cache? lol

view source and it shows up, i need a way to just call it through php.

ex of what i mean:


function msgbox(msg)
{
alert (msg);
}


server sends "message: blah"

case = "message":
(this is where i need to call function without using echo/print)



any hints??


thanks

Posted: Wed Feb 02, 2005 8:50 pm
by feyd
not possible, that I know of.

You'll need to engineer a Javascript function to periodicly look at the body text for these messages...

what's the purpose of this?

Posted: Wed Feb 02, 2005 9:34 pm
by RayonMazter
making a webversion of a game i made,

purpose is that server sends player list,
then sends a certain string whenever a new player logs in, or someone logs out (which requires the function).


but u just gave me the best idea, thanks.

i'll have php do this

data comes, then it does

echo 'var NewPlayer=' . $data . ";";


then i can just have the function (like u said ) call every few seconds to update the new info,


never would have thought. Thanks again

Rayon