I used it to my own convenience:
function save (title, url) { (Var i = 1; i & lt; localStorage.length; i ++) {local storage ["save-title_" + + + "" = = title; Local storage ["saved-url_" + + + ""] = url; }} Function list favas () {for (var i = 1; i & lt; localStorage.length; i ++) {console.log (local storage ["save-foot-title_" + + + "" "]]; }}
() occurs when someone clicks on it:
onclick = "save (\ '+ + + +' \ ', \' + + Tab.url + '' '); "& Gt; '+ Title +' & lt; / a & gt; ';
However ... does not show saved local storage, How do I get it done?
May be because you save the key to ' Save-title_ '+ i
and ' saved-fav-title_ '+ i
to recover it?
The difference between Fav - section.
And your calculation is bound to create local storage errors because There is no guarantee that there is a key to all items in it which corresponds to the 'saved-fav-title_' + i
provided system - in fact it is not guaranteed to do as you In the form of themselves as the 'saved-url _' + i
are input.
Therefore, if you want to match the item with the pattern of the key Use the
function listFavs () for {var key; (var i = 0, len = localStorage.length; I & lt; Len; I ++) {key = localStorage.key (i); If ((/ / ssaved-fav-title _ /) test (key)} {console.log (localStorage.getItem (key);}}}
Comments
Post a Comment