<!-- HTML -->
<html>
<head>
<title> name</title>
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<p id = "name"></p>
<script src = "index.js">
var x = "Hello my name is " + localStorage.getitem("text");
document.getElementById("name").innerHTML = x;
</script>
</body>
</html>
I have put some text into local storage and now I want to add that text to the page through HTML by inserting it into the paragraph. For example if I asked for someones name on one page, stored it in local storage and then on the next page I could Say: "Hello Steve".
edit: moving the script has no effect on the outcome. The information is definitely being stored because if I use to call a function that uses:
document.write("
Hi " + localStorage.getItem("text") + "
")then the text will appear on the screen but the rest of the body will not load. So for example if i wanted a background color that would not work. To me this makes it seem that this is not a duplicate of the other question.