PHP daemon and JavaScript two ways to interact _php tutorial

Source: Internet
Author: User
Method One: Interact with cookies.
There are altogether three files, respectively: index.htm,action.php,main.htm
Principle for the foreground page main.htm and background action.php through the page frame index.htm organized, the width of the action.php page is set to 0, so that does not affect the display. Action.php the information into a cookie, main.htm the interaction by reading the cookie. Control of the background CGI program can also be achieved in main.htm by re-reading the action.php.
Index.htm
Copy CodeThe code is as follows:


<title>Test</title>





&lt;noframes&gt;&amp;lt;br&amp;gt;&amp;lt;body bgcolor= "#FFFFFF" &amp;gt; &amp;lt;BR&amp;gt;&amp;lt;p&amp;gt; page frames are used, but not supported by your browser. &amp;lt;/p&amp;gt; &amp;lt;BR&amp;gt;&amp;lt;/body&amp;gt; &amp;lt;BR&amp;gt;&lt;/noframes&gt;


action.php
Copy CodeThe code is as follows:
Srand (Double) microtime () *1000000);
$result =rand (0,100);
Setcookie ("Action", $result, Time () +900, "/");
?>

Main.htm
Copy CodeThe code is as follows:


<title>Test</title>








Re-reading Cookies



Method Two: Directly through the parent.*.* to realize the interaction.
There are altogether three files, respectively: Index.htm,action.php,main.htm, of which index.htm is the same as in front.
The principle is to pass information directly through Parent.rightFrame.test.current_cookie.value.
action.php
Copy CodeThe code is as follows:
Srand (Double) microtime () *1000000);
$result =rand (0,100);
?>


Main.htm
Copy CodeThe code is as follows:


<title>Test</title>






Re-reading Cookies


http://www.bkjia.com/PHPjc/320746.html www.bkjia.com true http://www.bkjia.com/PHPjc/320746.html techarticle method One: Interact with cookies. Total is three files, respectively: index.htm,action.php,main.htm principle for the front page main.htm and backstage action.php through the page frame index.htm organization ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.