Jump to content

help with passing js command with php to a parent page


GD77

Recommended Posts

Javascript is run in the browser, in the HTTP response.

 

It's impossible to execute a JS command before the HTTP header is sent.

 

If you explain what you're trying to do, there's probably an alternative solution.

Link to comment
Share on other sites

PS - if you just want to run a JS command as soon as the page loads, do this:

<html>
  <head>
    <script type="text/javascript">
      parent.function();
    </script>

 

That will execute before the HTML renders.

Link to comment
Share on other sites

PS - if you just want to run a JS command as soon as the page loads, do this:

<html>
  <head>
    <script type="text/javascript">
      parent.function();
    </script>

 

That will execute before the HTML renders.

 

Actually that is what I ve done:

$msg="Welcome, You Are Logged In.";

sleep(2);

echo "<script type='text/javascript'>parent.boxOFF();</script>";

 

and it s working but now the echo command is preventing the $msg data from showing

Link to comment
Share on other sites

echo solved the delay and the $msg problem with this:

 

$msg="Welcome, You Are Logged In.

            <script type='text/javascript'>

function delayed(){parent.boxOFF();parent.location.reload(true);}

    window.setTimeout(delayed,2000);</script>";

 

Don t know if their is a another or better way...

Thanks again.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.