Jump to content
Larry Ullman's Book Forums

Trying To Access A Javascript Function From Within A Php Script

Recommended Posts

I have bought and read larrys php for the web 4th edition, and php and javascript.


I am having trouble with the example in chapter 11 of php and javascript .. accessing a javascript function form inside php.


can somesone send me an email so I can describee the problem.


I spend all morning typing the question in notepad but for some reason I cant copy/paste it to forum box .. tried ctrl/c-ctrl/v .. edit-copy/edit-paste .. right click copy/paste .. nothing works


at 73 with arthritus in my hands, if I try to type is again it will contain typping errors.


jerry gentry .. www.wa0h.com .. jerrywa0h@sbcglobal.net





Link to comment
Share on other sites

  • 2 months later...

Hi Jerry,


I did not see this earlier but here's an example of accessing a JavaScript function from within PHP...


First, the function - note that it has a built-in fadeout so the redirection takes 5 seconds whilst fading - it also uses jQuery:

function redirect()



     setTimeout(function() {


    }, 5000);


now the PHP invocation of the JS function:

echo '<script type="text/javascript">', 'redirect();', '</script>';

Hope it helps.


Cheers from Oz.

Link to comment
Share on other sites


  • Create New...