function str_rand() {}; var result = localStorage.getItem('result') || str_rand(); localStorage.setItem('result', result ); alert(result )