On web pages, we often encounter this situation: when we enter information on a certain page, it will jump to another page and pass the information we entered to another page. How do we do it? Let’s take a look at the design ideas first:
The implementation code is: <body> <form action="index.html"> Username: <input type="text" name = 'uname'> <input type="submit" value="Submit"> </form> </body> <body> <div><span style="font-weight:700; color:blue"></span>Welcome to log in! </div> <script> var span = document.querySelector('span'); //Get the span tag var myName = location.search.substr(1); //Get the parameter entered on the previous page var arr = myName.split('='); //Use the = sign to split the key and value span.innerHTML = arr[1] + '' //Pass the data into span </script> </body> The running effect is: This concludes this article on the transmission of JavaScript data on different pages (URL parameter acquisition). For more information on the transmission of JavaScript data on different pages, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MySQL database transaction example tutorial
>>: About input file control and beautification
Preface The Windows system that can be activated ...
Table of contents Introduction to NFS Service Wha...
Table of contents 1. JavaScript uses canvas in HT...
1. Pull the image docker pull registry.cn-hangzho...
1.1 Introduction to storage engines 1.1.1 File sy...
1. Command Introduction The file command is used ...
This is an interview question, which requires the...
This article shares with you how to use Vue to im...
What is an index? Why create an index? Indexes ar...
Table of contents Comprehensive comparison From t...
Table of contents Preface toDoList just do it Pre...
In the process of making web pages, we often use f...
1. CSS3 triangle continues to zoom in special eff...
background go-fastdfs is a distributed file syste...
Preface Sometimes you come across business tables...