简体   繁体   English

如何将用户输入从一个 html 页面显示到另一个 html 页面 (javascript)

[英]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.

相关问题 使用 JavaScript 从一个 HTML 页面和 output 到另一个 Z4C4AD5FCA2E7A18AA74DBB1CED003 页面获取输入 - Using JavaScript to take input from one HTML page and output to another HTML page 如何从HTML页面中的用户显示获取输入 - How to get input from user display in HTML page 如何在JavaScript中将值从一个html页面传递到另一个页面? - How to pass value from one html page to another in JavaScript? 如何将javascript / jquery函数从一个HTML页面传递到另一HTML页面 - How to pass a javascript/jquery function from one html page to another 如何使用javascript将数据从一个html页面传输到另一页面 - how to transfer data from one html page to another using javascript JavaScript在另一个HTML页面上显示HTML值 - JavaScript to display HTML values on another HTML page 如何将 javascript 变量值从一个 html 页面传递到另一个 html 页面? - How to pass the javascript variable value from one html page to the another html page? 如何使用javascript将值从一个html页面传递到另一个html页面 - How can I pass values from one html page to another html page using javascript 如何仅使用JavaScript将表单数据从一个HTML页面传递到另一HTML页面? - How do I pass form data from one HTML page to another HTML page using ONLY javascript? 通过 JavaScript 将变量从一个 html 页面传递到另一个页面 - Passing Variable through JavaScript from one html page to another page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM