HTML page Jump and parameter transfer, page Jump Transfer

Source: Internet
Author: User

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 ';

 

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.