HTML page Jump and parameter transfer, page Jump Transfer
HTML page Jump:
Window. open (url, "", "width = 600, height = 400 ");
The second parameter is _ self, which opens a window in the current window; _ blank (default), which opens a new window in another new window;
Window. location. href = "http://www.jb51.net"; // open a window in the same current window
Window. history. back (-1); // return to the previous page
<A href = "http://www.baidu.net" target = "_ blank">
HTML parameter transfer:
1. parameter passing through url:
The first page (a.html ):
Var obj = a. value; // pass the parameter to the pop-up page
Var url = 'jxb.html? Obj = '+ obj;
Url = encodeURI (url );
Window. open (url, "", "width = 600, height = 400 ");
The second page (B .html ):
Var url = decodeURI (window. location. href );
Var argsIndex = url. split ("? Obj = ");
Var arg = argsIndex [1];
Note: Chinese transmission: You can use encodeURI to encode the url on page a and decodeURI to decode the url on page B.
2. cookie parameter passing:
function setCookie(cname,cvalue){ document.cookie = cname + "=" + cvalue;}function getCookie(cname){ var name = cname + "="; var ca = document.cookie;}
3. Passing parameters from the localStorage object:
A.html:
Var div = doucment. getElementById ('get the div id of the string ');
LocalStorage. string = div. textContent;
B .html:
Var div = doucment. getElementById ('div ID to be written name ');
Div. textContent = localStorage. string;
4. window. opener ()
Parent page:
<Input type = "text" name = "textfield" id = "textfield"/>
Window. open ("subpage .html ");
Subpage:
Optional values opener.doc ument. getElementByIdx ('textfield'). value = '20140901 ';