Two ways of interacting between php background program and Javascript_PHP Tutorial

WBOY
Release: 2016-07-21 15:43:19
Original
1275 people have browsed it

Method 1: Interaction through Cookies.
There are three files in total, namely: index.htm, action.php, main.htm
The principle is that the front page main.htm and the background action.php are organized through the page frame index.htm, and the action. The page width of php is set to 0, which does not affect the display. action.php puts information into cookies, and main.htm implements interaction by reading cookies. In main.htm, you can also control the background CGI program by re-reading action.php.
index.htm

Copy code The code is as follows:



Test





<br><body bgcolor="# FFFFFF"> <br><p>This page uses page frames, but your browser does not support it. </p> <br></body> <br>


action.php
Copy code The code is as follows:

srand((double)microtime()*1000000);
$result=rand( 0,100);
setcookie("action",$result,time()+900,"/");
?>

main.htm
Copy code The code is as follows:



Test





The current parameter is




Reread Cookie



Method 2: Interaction is achieved directly through parent.*.*.
There are three files in total, namely: index.htm, action.php, main.htm, of which index.htm is the same as the previous one.
The principle is to pass information directly through parent.rightFrame.test.current_cookie.value.
action.php
Copy code The code is as follows:

srand((double)microtime ()*1000000);
$result=rand(0,100);
?>


main.htm
Copy code The code is as follows:



Test




The current parameters are



< a href="action.php" target="leftFrame">Reread Cookie


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320746.htmlTechArticleMethod 1: Interaction through Cookies. There are three files in total, namely: index.htm, action.php, main.htm. The principle is that the front page main.htm and the backend action.php are organized through the page frame index.htm...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template