There is a relationship between the two windows. Parent window parent.htm Opened sub-window SON.HTM
The sub-window can point to the parent window via Window.opener. This allows you to access the object of the parent window.
Advantages: It is convenient for value. As long as Window.opener points to the parent window, you can access all objects.
Not only can you access a value, but also the method of the parent window. The value is not limited.
Disadvantages: There is a relationship between the two windows. It is the window opened by Window.Open. You cannot cross the domain.
Post.htm
Read.htm
//Window.open opens the window.
// Use Opener to point to the parent window.
Var ParentText = WINDOW.Opener.document.all.maintext.Value;
Alert (ParentText);
script>
Use cookie.
Cookie is a browser store a small number of named data.
It is associated with a particular web page or website.
Cookie is used to provide memory for your browser.
In order to use the input data of another page in a page.
Advantages: Access can be accessed anywhere within the homology. The life period can be set.
Disadvantages: The value is limited.
Post.htm
Function setCookie (Name, Value)
{
/ *
* --------------- SetCookie (Name, Value) -----------------
* SetCookie (Name, Value)
* Function: Set the value of the variable Name
* Parameters: Name, string; value, string.
* Instance: 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 the page.
}
script>
Read.htm
Function getCookie (Name)
{
/ *
* --------------- GetCookie (name) -----------------
* GetCookie (Name) * Function: Take the value of the variable Name
* Parameters: Name, string.
* Example: Alert ("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 ("baobao");
script>
URL
You can pass the URL. Put the information to be passed on the URL.
Advantages: Easy to take. You can cross domain.
Disadvantages: The value is limited.
Post.htm
Function Post ()
{
// Single value read.htm? Username = baobao;
// Multi-value read.htm? Username = baobao & sex = male;
URL = "read.htm? username =" escape (document.all.username.value);
URL = "& sex =" escape (document.all.sex.value);
Location.href = URL;
}
script>
Read.htm
/ *
* --------------- Read.htm -----------------
* Request [key]
* Function: Realize the acquisition of the ASP URL string, Request ("AAA")
* Parameters: Key, string.
* Instance: Alert (Request ["AAA"])
* Author: wanghr100 (Gray Beans Baby .NET)
* Update: 2004-6-11 10:30
* --------------- Request.htm -----------------
* /
Var URL = location.search;
Var Request = new object ();
IF (URL.INDEXOF ("?")! = - 1)
{
Var str = url.substr (1) // remove?
STRS = Str.Split ("&");
For (var i = 0; i { Request [strs [i] .split ("=") [0]] = UNESCAPE (STRS [i] .split ("=") [1]); } } Alert ("UserName"]) ALERT (Request ["SEX"]) script>