How to correctly implement PHP and JavaScript interaction _php Tutorial

Source: Internet
Author: User
We are using

The way PHP interacts with javascript: interacting with cookies. There are altogether three documents, respectively:

Index.htm,action.php,main.htm

Principle for the foreground page main.htm and backstage action.php through the page frame, index.htm organization, 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 by reading
Cookies to enable interaction. Control of the background CGI program can also be achieved in main.htm by re-reading the action.php.

Implementation code for PHP interaction with javascript:

 
 
  1. < html >
  2. < head >
  3. < title>Test< /title >
  4. < meta http-equiv="Content-type"
    content = "text/html; charset=gb2312 ">
  5. < /head >
  6. < frameset framespacing = " 0 "
    border = "false" frameborder = "0" cols = "0,*" >
  7. < frame name = "Leftframe" scrolling = "No"
    noresize src = "action.php" >
  8. < frame name="rightframe " Scrolling="Auto"
    src = "Main.htm" >
  9. < /frameset > < noframes >
  10. < body bgcolor="#FFFFFF">
  11. < p> page frames are used, but your browser does not support them. < / p>
  12. < /body >
  13. < /noframes >
  14. < /html >
  15. < ?
  16. Srand (Double) microtime () *1000000);
  17. $ result = Rand (0,100);
  18. Setcookie ("Action", $result, Time () 900, "/");
  19. ?>

The above is the specific implementation of PHP and JavaScript interaction.


http://www.bkjia.com/PHPjc/446054.html www.bkjia.com true http://www.bkjia.com/PHPjc/446054.html techarticle we're using PHP to interact with javascript: interacting with cookies. Total is three files, respectively: index.htm,action.php,main.htm principle for the front page main.htm and backstage acti ...

  • Related Article

    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.