-4

我的代码有什么问题?

第一帧

<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>

我无法使用它计算来自另一个框架的单击按钮的数量。*不是我自己的代码

4

1 回答 1

2

您永远不会将任何数据写入本地存储。您无法获取不存在的项目。

于 2013-03-07T14:57:25.743 回答