使用localstorage检查的Javascript

时间:2017-12-06 09:19:14

标签: javascript html

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获取数据。

0 个答案:

没有答案