求JS和html5大神进来看看,localstorage本地储存的代码在自己电脑好用在别人电脑就不运行了,特别急!
代码如下代码如下,我的思路就是先把localstorage里的key都遍历一遍,存到一个数组里,然后遍历这个数组,来检查账号注册是否重复,这段代码在自己电脑上好用,但是去...
代码如下
代码如下,我的思路就是先把localstorage里的key都遍历一遍,存到一个数组里,然后遍历这个数组,来检查账号注册是否重复,这段代码在自己电脑上好用,但是去了别的电脑上也是chrome浏览器却不运行了,求大神解答!
function SUBMIT(){
var account=document.getElementById("account2").value;
var password=document.getElementById("password2").value;
var accounts=new Array();
for(var i=0;i<window.localStorage.length;i++){
var key=window.localStorage.key(i);
accounts.push(key);
}
for(var j=0;j<accounts.length;j++){
if(account==accounts[j]){
alert("This account was registered.");
return;
}
else{
window.localStorage.setItem(account,password);
document.getElementById("shadow").style.visibility="hidden";
document.getElementById("reg").style.visibility="hidden";
}
}
} 展开
代码如下,我的思路就是先把localstorage里的key都遍历一遍,存到一个数组里,然后遍历这个数组,来检查账号注册是否重复,这段代码在自己电脑上好用,但是去了别的电脑上也是chrome浏览器却不运行了,求大神解答!
function SUBMIT(){
var account=document.getElementById("account2").value;
var password=document.getElementById("password2").value;
var accounts=new Array();
for(var i=0;i<window.localStorage.length;i++){
var key=window.localStorage.key(i);
accounts.push(key);
}
for(var j=0;j<accounts.length;j++){
if(account==accounts[j]){
alert("This account was registered.");
return;
}
else{
window.localStorage.setItem(account,password);
document.getElementById("shadow").style.visibility="hidden";
document.getElementById("reg").style.visibility="hidden";
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询