Make sure the div exists before trying to reference it,
window.addEventListener("load",function() {
document.getElementById('text').innerHTML = localStorage.getItem("mytext");
},false);
That will wait for the document to load before doing any modifications
1
solved Whats wrong here, why is innerHTML not working? [closed]