In the onload
event you should read the local storage and set it in the textbox there is a value stored, otherwise make it "First try".
window.onload = function(){
var val = localStorage.getItem('value'); // or localStorage.value
if(val == null)
val = "First try";
document.getElementById("myData").value = val;
}
In the onbeforeunload
event you should retrieve the value of the textbox and save it in the local storage.
window.onbeforeunload = function(){
localStorage.setItem('value', document.getElementById("myData").value); // or localStorage.value = document.getElementById("myData").value
}