【发布时间】:2015-01-24 14:33:39
【问题描述】:
我正在使用 html/css/js 制作日历。 我有一个 index.html :
<html>
<head>
<title>App calendario</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="myfunc.js"></script>
</head>
<body>
<form>
<button class="button-customize" onclick="MyFunction(4)" type="button">4 - 10</button>
</form>
</body>
js是:
function MyFunction(x) {
window.open("settimana.html","_self");
document.getElementById("Giorno_1").innerHTML = x;}
另一个页面 settimana.html 是:
<html>
<head>
<title>Settimana</title>
<link rel="stylesheet" href="./style.css" type="text/css" />
<script src="myfunc.js"></script>
</head>
<body>
<form action="#">
<button class="button-customize" type="submit" id="Giorno_1" name="Giorno_1">Giorno 1</button>
</form>
</body>
</html>
问题在于页面 settimana.html 中按钮的值没有改变。为什么?请帮帮我。
【问题讨论】:
-
settimana 和 index 都使用同一个脚本文件,但这并不意味着它们共享同一个脚本文件。它们在内存中都有一个副本,因此其中一个的更改不会影响另一个。您需要在加载之前传递所需的任何数据。
标签: javascript html function button