Advertisement
Guest User

Example iphone button

a guest
Sep 26th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.90 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Test</title>
  5.         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js" type="text/javascript"></script>
  6.         <script src="http://papermashup.com/demos/ajax-switch/jquery.iphone-switch.js" type="text/javascript"></script>
  7.         <script>
  8.             var refreshTimer;
  9.  
  10.             function enableTimer()
  11.             {
  12.                 refreshTimer = setTimeout(function(){ location.reload(true); }, 5000);
  13.                 window.location.hash = "#autoreload";
  14.             }
  15.            
  16.             function disableTimer()
  17.             {
  18.                 clearTimeout(refreshTimer);
  19.                 window.location.hash = "";
  20.             }
  21.            
  22.             $(function() {
  23.            
  24.                 $('#button').iphoneSwitch(
  25.                     (window.location.hash == "#autoreload" ? "on" : "off"),
  26.                     enableTimer,
  27.                     disableTimer
  28.                 );
  29.                
  30.                 if (window.location.hash == "#autoreload")
  31.                     enableTimer();
  32.             });
  33.  
  34.         </script>
  35.     </head>
  36.     <body>
  37.    
  38.         <div id="button"></div>
  39.     </body>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement