How do I get to list down the stored records in the for loop?
Basically I want it to list down the records like this:
'<div id="record_' + number + '">' + localstorage value + '</div>'
The number in the class should add 1 every record, e.g. 1, 2, 3, 4 every record it lists down, and so on.
The localstorage value should show the localStorage[] but the problem is, the localStorage name has the same, e.g.
(clicks on button)
it will save the value of the URL into a localStorage
I then open the application and shows the window.html
inside there is list of stored records by using this:
'<div id="record_' + number + '">' + localstorage value + '</div>'
INCLUDING the record number to add per record 1, 2, 3, etc... like this:
<div id="record_1">localstorage value</div>
<div id="record_2">localstorage value</div>
<div id="record_3">localstorage value</div>
<div id="record_4">localstorage value</div>
<div id="record_5">localstorage value</div>
<div id="record_6">localstorage value</div>
etc...
EDIT:
for (var i = 1; i < localStorage.length; i++) {
document.write('<div id="record_' + i + '">' + i + '<span style="float:right;"><ahref="#" onclick="javascript:clear(' + i + ');">Delete</a></span></div>');
}
window.addEventListener("load", windowLoaded, false);
function windowLoaded()
{
chrome.tabs.getSelected(null, function(tab)
{
var btn = '<a href="' + tab.url + '" onclick="Save(\'' + tab.url + '\');">Add to Favourites</a>';
document.getElementById('current-link').innerHTML = '<p>' + btn + '</p>';
});
}
function Save(url)
{
localStorage.setItem("cilium-favs", url);
}