HTML page jump and parameter transfer issues

HTML page jump and parameter transfer issues

HTML page jump:

window.open(url, "", "width=600,height=400");

The second parameter: _self, opens the window in the current window; _blank (default value), opens the new window in another new window;

window.location.href="https://www.jb51.net"; //Open the 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 passing:

1. URL parameter passing:

The first page (a.html):

var obj = a.value; // Pass to pop-up page parameter 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: For 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 transmission:

function setCookie(cname,cvalue){
    document.cookie = cname + "=" + cvalue;
}
function getCookie(cname){
    var name = cname + "=";
    var ca = document.cookie;
}

3. localStorage object parameter passing:

a.html:

var div = doucment.getElementById('DIV ID name to get the string');
localStorage.string = div.textContent;

b.html:

var div = doucment.getElementById('DIV ID name to be written');
div.textContent = localStorage.string;

4. window.opener()

Parent page:

<input type="text" name="textfield" id="textfield"/>
window.open("subpage.html");

Subpages:

window.opener.document.getElementByIdx('textfield').value='123123123';

Summarize

The above is the editor's introduction to HTML page jump and parameter passing issues. I hope it will be helpful to everyone. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

<<:  The difference between absolute path and relative path in web page creation

>>:  Implementation of new issues of CSS3 selectors

Recommend

Example of implementing grouping and deduplication in MySQL table join query

Table of contents Business Logic Data table struc...

How to Clear Disk Space on CentOS 6 or CentOS 7

Following are the quick commands to clear disk sp...

Fixed table width table-layout: fixed

In order to make the table fill the screen (the re...

Detailed Example of Row-Level Locking in MySQL

Preface Locks are synchronization mechanisms used...

Specific method of viewing user authorization information in mysql

Specific method: 1. Open Command Prompt 2. Enter ...

How to install Nginx in Docker

Install Nginx on Docker Nginx is a high-performan...

CSS method of controlling element height from bottom to top and from top to bottom

Let’s start the discussion from a common question...

MySQL and sqlyog installation tutorial with pictures and text

1. MySQL 1.1 MySQL installation mysql-5.5.27-winx...

Docker View JVM Memory Usage

1. Enter the host machine of the docker container...

How to import Chinese data into csv in Navicat for SQLite

This article shares with you the specific method ...

Building a Redis cluster on Docker

Table of contents 1. Pull the image 2. Create a R...

In-depth analysis of Flex layout in CSS3

The Flexbox layout module aims to provide a more ...