Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Auto refresh</title>
- </head>
- <body>
- <label><input type="checkbox" name="chk_refresh" onchange="swith_refresh();" id="chk_refresh">Auto refresh</label>
- <div>
- Random number (for reload test): <span id="span_rnd"></span>
- </div>
- <script type="text/javascript">
- chk_refresh.checked = ( localStorage.is_refresh == 1 );
- span_rnd.innerHTML = Math.random();
- function swith_refresh(){
- if ( chk_refresh.checked ){
- localStorage.is_refresh = 1;
- refresh_after_timeout();
- } else {
- localStorage.is_refresh = 0;
- }
- }
- function refresh_after_timeout(){
- setTimeout( function(){
- location.reload();
- }, 2000 );
- }
- if ( localStorage.is_refresh == 1 ){
- refresh_after_timeout();
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement