Possible Duplicate:
Automatic page refresh
I found this on and off switch online and would like to use it to refresh a page. If the user click the “on” it will refresh the page every 5 seconds. If they click off it will stop. Can some please help me out. Here’s what I have so far:
<style>
body{
font-family:Verdana, Geneva, sans-serif;
font-size:14px;}
.left{
float:left;
width:120px;}
#ajax{
float:left;
width:300px;
padding-top:5px;
font-weight:700;
}
.clear{clear:both;}
</style>
</head>
<body>
</a></div>
<div id="container">
<div class="left" id="1"></div>
<div id="ajax"></div>
<div class="clear"></div>
<script type="text/javascript">
$('#1').iphoneSwitch("on",
function() {
$('#ajax').load('on.html');
},
function() {
$('#ajax').load('off.html');
},
{
switch_on_container_path: 'iphone_switch_container_off.png'
});
</script>
You can enable and disable page refresh like this:
If you want to reload some html using ajax you can use something like this (using setInterval):
Edit
In this example page reloading is disabled by default, when the users enables it using the button it will stay on untill disabled