How to correctly implement PHP and Javascript Interaction

Source: Internet
Author: User

We are using

How PHP interacts with Javascript: Through cookies. There are three files in total:

Index.htm,action.php, main.htm

The principle is that the front page main.htmand the rear action.php are connected to the page frame, and index.htm is organized to set the page width of action. php to 0, which does not affect the display. Action.php puts the information into cookie, and main.htm reads the information
Cookie. In main.htm, you can also control the background CGI program by re-reading action. php.

PHP and Javascript interaction implementation code:

 
 
  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> This page uses the page framework, but your browser does not support it. </P>
  12. </Body>
  13. </Noframes>
  14. </Html>
  15. <?
  16. Srand (double) microtime () * 1000000 );
  17. $ Result = revert (0,100 );
  18. Setcookie ("action", $ result, time () 900 ,"/");
  19. ?>

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


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.