简体   繁体   English

使用jQuery在两个HTML页面之间传递数据

[英]pass data between two html pages using jquery

How can I pass variables between two html pages using jQuery? 如何使用jQuery在两个HTML页面之间传递变量?

file1.html 的file1.html

<form>
  First name : <input type="text" id="firstname"/>
</form>

file2.html: file2.html:

<p> <!--retrieve firstname here --> </p>

You could use localStorage: 您可以使用localStorage:

// Store (on first page)
localStorage.setItem("firstname", "Smith");

// Retrieve (on second page)
var firstname = localStorage.getItem("firstname"); 

More info: http://www.w3schools.com/html/html5_webstorage.asp 更多信息: http : //www.w3schools.com/html/html5_webstorage.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM