【发布时间】:2017-03-02 05:58:34
【问题描述】:
使用 javascript 将值从一个 html 页面传递到另一个 html 页面 以下是我的代码: 第一个页面为 html1.html:
<!DOCTYPE html>
<html>
<head>
<script>
function newDoc()
{
window.location.assign("html2.html");
}
</script>
</head>
<body>
<input type="button" value="submit" onclick="newDoc ()">
</body>
</html>
而第二个html代码为html2.html:
<!DOCTYPE html>
<html>
<head>
<script>
function newDoc()
{
window.location.assign("html1.html");
}
</script>
</head>
<body>
<input type="button" value="submit" onclick="newDoc ()">
</body>
</html>
【问题讨论】:
-
也许你可以尝试将值存储在localStorage
-
使用一些cookies?
-
为什么不简单地使用 POST 或 GET?
标签: javascript html