Method One: Interact with cookies.
A total of 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 action.php page width set to 0, this does not affect the display. Action.php the information into a cookie and main.htm the interaction by reading the cookie. In Main.htm, you can also control the background CGI program by re-read the action.php.
Index.htm
Copy Code code as follows:
<title>Test</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<frameset framespacing= "0" border= "false" frameborder= "0" cols= "0,*" >
<frame name= "Leftframe" scrolling= "no" noresize src= "action.php" >
<frame name= "Rightframe" scrolling= "Auto" src= "main.htm" >
</frameset><noframes>
<body bgcolor= "#FFFFFF" >
<p> page frames are used on this page, but your browser is not supported. </p>
</body>
</noframes>
action.php
Copy Code code as follows:
<?php
Srand (Double) microtime () *1000000);
$result =rand (0,100);
Setcookie ("Action", $result, Time () +900, "/");
?>
Main.htm
Copy Code code as follows:
<title>Test</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<script language= "JavaScript" >
function Get_cookie ()
{
Document.test.current_cookie.value=document.cookie;
}
</script>
<body bgcolor= "#FFFFFF" >
<form name= "Test" >
The current parameter is <input type= "text" name= "Current_cookie" size= "M" maxlength= "1000" >
</form>
<script language= "JavaScript" >
SetInterval ("Get_cookie ()", 200);
</script>
<br>
<a href= "action.php" target= "Leftframe" > re-read cookie</a>
</body>
Method Two: Directly through Parent.*.* to realize the interaction.
A total of three files, respectively: Index.htm,action.php,main.htm, where index.htm and the same as before.
The principle is to transmit information directly through Parent.rightFrame.test.current_cookie.value.
action.php
Copy Code code as follows:
?
Srand (Double) microtime () *1000000);
$result =rand (0,100);
?>
<script language= "JavaScript" >
Parent.rightframe.test.current_cookie.value= ". echo $result?> ";
</script>
Main.htm
Copy Code code as follows:
<title>Test</title>
& L T;meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body bgcolor=" #FFFFFF ">
<form name=" Test >
Current parameter is &L T;input type= "text" name= "Current_cookie" size= "no" maxlength= "1000" >
</form>
<br>
<a href= "action.php" target= "Leftframe" > re-read cookie</a>
</body>