var site = document.getElementById('display').innerHTML =
document.getElementById("site").value;
var link = document.getElementById('displayy').innerHTML =
document.getElementById("link").value;
var t = true;
var both = [site,link];
while (t == true){
var s = 0;
var y = 0;
var check = localStorage.getItem(y);
if (check === null){
localStorage.setItem(s , both);
alert(y);
break;
} else {
var s = s + 1;
var y = y + 1;
localStorage.setItem(s , both);
}
}
Javascript应该检查0 = emty,如果是,那么如果没有检查1检查2检查3等,则将其添加到localstorarge。我从html获取数据。