static | page There is a relationship between the two windows. Parent Window parent.htm Open child window son.htm
A child window can point to a parent window by Window.opener. This allows access to the object of the parent window.
Advantage: The value is convenient. You can access all objects as long as the window.opener points to the parent window.
You can access not only the values, but also the methods of the parent window. The value length is unlimited.
Disadvantages: Two windows have a relationship. is the window that is opened using window.open. Cannot cross domain.
<script language= "JavaScript" >
window.open the open window.
Use opener to point to the parent window.
var parenttext = Window.opener.document.all.maintext.value;
alert (Parenttext);
</script>
Use cookies.
A cookie is a browser that stores a small number of named data.
It is associated with a particular Web page or Web site.
Cookies are used to provide memory to the browser,
So that scripts and server programs can use the input data from another page in one page.
Advantages: can be accessed in any Web page within the same source. The lifetime can be set.
Disadvantage: The value length is limited.
Post.htm
<input type= "text" name= "Txt1" >
<input type= "button" value= "Post" >
<script language= "JavaScript" >
function Setcookie (name,value)
{
/*
*---------------Setcookie (name,value)-----------------
* Setcookie (Name,value)
* Function: Set the value of the variable name
* Parameter: Name, string; value, String.
* Example: Setcookie (' username ', ' Baobao ')
* Update:2004-6-11 10:30
*---------------Setcookie (name,value)-----------------
*/
var days = 30; This cookie will be saved for 30 days
var exp = new Date ();
Exp.settime (Exp.gettime () + days*24*60*60*1000);
Document.cookie = name + "=" + Escape (value) + "expires=" + exp.togmtstring ();
Location.href = "read.htm"; Receive page.
}
</script>
Read.htm
<script language= "JavaScript" >
function GetCookie (name)
{
/*
*---------------GetCookie (name)-----------------
* GetCookie (name)
* Function: Get the value of the variable name
* Parameter: Name, String.
* Example: Alert (GetCookie ("Baobao"));
* Update:2004-6-11 10:30
*---------------GetCookie (name)-----------------
*/
var arr = Document.cookie.match (New RegExp ("(^|)" +name+ "= ([^;] *)(;|$)"));
if (arr!=null) return unescape (arr[2)); return null;
}
Alert (GetCookie ("Baobao"));
</script>
URL Chapter
Can pass the value of the URL. Connect the information you want to pass to the URL.
Advantages: Easy to value. can cross domain.
Disadvantage: The value length is limited.
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.