[英]How to display user input from one html page to another html page (javascript)
I have one HTML page (test.html)我有一个 HTML 页面 (test.html)
<!DOCTYPE html>
<html lang="en">
<head>
<title>test</title>
</head>
<body>
<input type="text" id="input-text" placeholder="Enter Text here"> <!--input text-->
<input type="button" id="btn" onclick="addText()" > <!--call function-->
<button ><a href="test2.html">Next Page</a></button> <!--get to new html page-->
</body>
<script src="app.js"></script>
</html>
and another HTML (test2.html)和另一个 HTML (test2.html)
<!DOCTYPE html>
<html lang="en">
<head>
<title>test2</title>
</head>
<body>
<h1 id="header">Display input here</h1>
</body>
<script src="app.js"></script>
</html>
I want to go from one page to the other.我想 go 从一页到另一页。 The first page has an input, and the second page should display the input made by the user at the first page.
第一页有一个输入,第二页应该显示用户在第一页所做的输入。 This is the JavaScript:
这是 JavaScript:
function addText()
{
document.getElementById('header').innerHTML
=document.getElementById('input-text').value;
}
How to display my user input from test page to test2 page?如何将我的用户输入从测试页面显示到 test2 页面?
Create a JSON object to store the data in localStorage.创建一个 JSON object 将数据存储在localStorage中。 Then pull that data from the object when loading the next page.
然后在加载下一页时从 object 中提取该数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.