Brick,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<script>
'use strict';
document.addEventListener("DOMContentLoaded", function() {
var title = localStorage.getItem("mes");
var div = document.querySelector(".txt");
var btn = document.querySelector('[type="button"]');
var oldTitle = div.innerHTML;
if (title) div.innerHTML = title;
btn.addEventListener("click", function() {
title = prompt("Сообщение:", "");
if(title === null) title = oldTitle;
div.innerHTML = localStorage.mes = title
})
});
</script>
</head>
<body>
<div class="txt" >нажми на кнопку, введи текст/не вводи/отмени, перезагрузи страницу</div>
<input type='button' value='Ok'>
</body>
</html>