我的代码出了什么问题?
第1帧
<script type="text/javascript">
var Clicks = 0 ;
function AddClick(){
Clicks = Clicks + 1;
document.getElementById('CountedClicks').innerHTML = Clicks ;
}
localStorage.setItem('Clicks');
</script>
</head>
Fish and Chips
<p align="right"> <input Type="BUTTON" VALUE="Order" onclick=" AddClick()"></p>
第2帧
<head>
<script type="text/javascript">
var loc = "";
function go() {
window.location.href = loc;
}
function set_loc(theURL) {
loc = theURL;
}
window.onload = function() {
div = document.getElementById("CountedClicks");
div.innerHTML=localStorage.getItem('variable');
}
</script>
</head>
<body>
<div id="container" style="background-color:#8A4117;height:30%;width:98%;borde-radius:15px" >
You have ordered <span id="CountedClicks">0 </span> items.<br>
<p align="right"><input type=submit name="Submit" value="Checkout" onchange="set_loc('pay.html');" /></a></p>
</div>
我无法使用此计算来自另一帧的点击按钮数。 *不是我自己的代码
答案 0 :(得分:2)
您永远不会将任何数据写入本地存储。你不能getItems不存在。