Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
JerryWa0h

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

 

 

 

 

Share this post


Link to post
Share on other sites

Hey Jerry. You really should be able to copy/paste here (sorry about your arthritis). Maybe try a different browser?

Share this post


Link to post
Share on other sites

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()

    {

     $('#fadeout_area').fadeOut(5000);

     setTimeout(function() {

       window.location.replace('./index.php?p=whatever');

    }, 5000);

    }

now the PHP invocation of the JS function:

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

Hope it helps.

 

Cheers from Oz.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...