Shyam sahani
Just copy past this code and change value
Use this code use for prasonlize webpage acording to user!
<!DOCTYPE html>
<html>
<body>
<div id="result">Shyam sahani</div>
<input type="text" placeholder="Enter your name " id="name">
<button onclick="update();">update</button>
<script>
function update(){
localStorage.setItem("name",document.getElementById("name").value);
document.getElementById("result").innerHTML = localStorage.getItem("name");
alert("Your name updated!");
}
// Check browser support
if (localStorage.getItem("name")==null) {
// Store
localStorage.setItem("name", document.getElementById("result").innerText);
// Retrieve
document.getElementById("result").innerHTML ="Welcome :"+localStorage.getItem("name");
} else {
document.getElementById("result").innerHTML ="Welcome : "+localStorage.getItem("name");
}
</script>
</body>
</html>
0 Comments