Method 1: use cookies for interaction.
There are three files in total: index.htm,action.php and main.htm
The original reason is that the main.htm and the background action. php are organized through the page framework index.htm and the page width of action. php is set to 0, which does not affect the display. Action.php adds the information to cookie, and main.htm reads cookies for interaction. In main.htm, you can also control the background CGI program by re-reading action. php.
Index.htm
Copy codeThe Code is as follows:
<Html>
<Head>
<Title> Test </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
</Head>
<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> This page uses the page framework, but your browser does not support it. </P>
</Body>
</Noframes>
</Html>
Action. php
Copy codeThe Code is as follows:
<? Php
Srand (double) microtime () * 1000000 );
$ Result = revert (0,100 );
Setcookie ("action", $ result, time () + 900 ,"/");
?>
Main.htm
Copy codeThe Code is as follows:
<Html>
<Head>
<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>
</Head>
<Body bgcolor = "# FFFFFF">
<Form name = "test">
The current parameter is <input type = "text" name = "current_cookie" size = "80" maxlength = "1000">
</Form>
<Script language = "javascript">
SetInterval ("get_cookie ()", 200 );
</Script>
<Br>
<A href = "action. php" target = "leftFrame"> re-read Cookie </a>
</Body>
</Html>
Method 2: directly implement interaction through parent.
There are three files in total: index.htm,action.php and main.htm,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 codeThe Code is as follows:
<?
Srand (double) microtime () * 1000000 );
$ Result = revert (0,100 );
?>
<Script language = "javascript">
Parent. rightFrame. test. current_cookie.value = "<? Echo $ result?> ";
</Script>
Main.htm
Copy codeThe Code is as follows:
<Html>
<Head>
<Title> Test </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
</Head>
<Body bgcolor = "# FFFFFF">
<Form name = "test">
The current parameter is <input type = "text" name = "current_cookie" size = "80" maxlength = "1000">
</Form>
<Br>
<A href = "action. php" target = "leftFrame"> re-read Cookie </a>
</Body>
</Html>