如何使用javascript使输入值显示在不同的页面中?
我正在尝试使我的一个html页面中的输入值显示在另一个html页面中 我的代码在第一页如下如何使用javascript使输入值显示在不同的页面中?,javascript,html,forms,input,project,Javascript,Html,Forms,Input,Project,我正在尝试使我的一个html页面中的输入值显示在另一个html页面中 我的代码在第一页如下 <div class="resume-input"> <h3>SUMMARY: </h3> <textarea name="Summary" placeholder="If its more than 100 words no one is going to read it" id="textarea" cols="30" rows="10"&
<div class="resume-input">
<h3>SUMMARY: </h3>
<textarea name="Summary" placeholder="If its more than 100 words no one is going to read it" id="textarea" cols="30" rows="10"></textarea>
</div>
window.location='results.html'允许按钮使用上一页的输入值将输入值重定向到另一页。在按钮上单击“将值存储在使用中” 并在加载
results.html
时检索
summaryInput.textContent = localStorage.getItem("anyKeyName")
另外,查看
窗口.onload
或者'results.html?sum='+summary
并阅读位置。搜索或者尝试本地/会话存储您可以将值存储在/中,然后以这种方式填充到另一个页面上。有一个错误:本地存储.set
是本地存储.setItem
和localStorage.getItem
而不是get
@E.Zacarias为这个错误道歉,感谢您指出它是做localStorage.set(“anyKeyName”)的,拉“文本区域的值在这里”,然后当您转到results.html时,您就把localStorage.get(“anyKeyName”)放在了上面要从上一页的文本区域中提取值,没有window.load这样的东西
document.querySelector('#button1').addEventListener('click', function(){
var summary = document.querySelector('#textarea').value;
var summaryInput = document.querySelector('#summary');
summaryInput.textContent = summary
window.location = 'results.html'
})
localStorage.setItem("anyKeyName","here goes the value from textarea")
summaryInput.textContent = localStorage.getItem("anyKeyName")