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

A brief discussion on the problem of forgotten mysql password and login error

If you forget your MySQL login password, the solu...

Native JS to achieve book flipping effects

This article shares with you a book flipping effe...

Causes and solutions to the garbled character set problem in MySQL database

Preface Sometimes when we view database data, we ...

MySQL 5.7.18 free installation version configuration tutorial

MySQL 5.7.18 free installation version installati...

Mysql | Detailed explanation of fuzzy query using wildcards (like,%,_)

Wildcard categories: %Percent wildcard: indicates...

How to install theano and keras on ubuntu system

Note: The system is Ubuntu 14.04LTS, a 32-bit ope...

Solve the problem of forgetting password in MySQL 5.7 under Linux

1. Problem Forgot password for mysql5.7 under lin...

HTML sample code for implementing tab switching

Tab switching is also a common technology in proj...

Eight rules for effective web forms

If you're collecting information from your us...

HTML basic summary recommendation (text format)

HTML text formatting tags 標簽 描述 <b> 定義粗體文本 ...

Detailed explanation of how to exit Docker container without closing it

After entering the Docker container, if you exit ...

How to install mysql in docker

I recently deployed Django and didn't want to...

MySQL 8.0.19 installation and configuration tutorial under Windows 10

I will be learning MySQL next semester. I didn...

Linux implements automatic and scheduled backup of MySQL database every day

Overview Backup is the basis of disaster recovery...

Writing High-Quality Code Web Front-End Development Practice Book Excerpts

(P4) Web standards are composed of a series of sta...