Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8581255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:00:15+00:00 2026-06-11T21:00:15+00:00

Possible Duplicate: Automatic page refresh I found this on and off switch online and

  • 0

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> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:00:16+00:00Added an answer on June 11, 2026 at 9:00 pm

    You can enable and disable page refresh like this:

    var refreshTimer;
    
    $('#button').iphoneSwitch("on", 
        function() {
            refreshTimer = setTimeout(function(){ location.reload(true); }, 5000);
        },
        function() {
            clearTimeout(refreshTimer);
        },
        {
            switch_on_container_path: 'iphone_switch_container_off.png'
        }
    );
    

    If you want to reload some html using ajax you can use something like this (using setInterval):

    var refreshTimer;
    
    function ajaxReload()
    {
        $.ajax .. etc
    }
    
    $('#button').iphoneSwitch("on", 
        function() {
            refreshTimer = setInterval(ajaxReload, 5000);
        },
        function() {
            clearInterval(refreshTimer);
        },
        {
            switch_on_container_path: 'iphone_switch_container_off.png'
        }
    );
    

    Edit

    In this example page reloading is disabled by default, when the users enables it using the button it will stay on untill disabled

    var refreshTimer;
    
    function enableTimer()
    {
        refreshTimer = setTimeout(function(){ location.reload(true); }, 5000);
        window.location.hash = "#autoreload";
    }
    
    function disableTimer()
    {
        clearTimeout(refreshTimer);
        window.location.hash = "";
    }
    
    $(function() {
    
        $('#button').iphoneSwitch(
            (window.location.hash == "#autoreload" ? "on" : "off"), 
            enableTimer, 
            disableTimer
        );
    
        if (window.location.hash == "#autoreload")
            enableTimer();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: C#: Public Fields versus Automatic Properties Duplicate? I think not: This question
Possible Duplicate: GCC STL bound checking Is there something like a automatic debug version
Possible Duplicate: Property Declaration and Automatic Backing Storage Allocation I'm really confused about this
Possible Duplicate: C#: Public Fields versus Automatic Properties Do I need to use {
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Automatic counter in Ruby for each? I want to find out the
Possible Duplicate: Automatic exit from bash shell script on error How can I have
Possible Duplicate: Can I create an automatic property (no private member) with get and
Possible Duplicate: std::string and its automatic memory resizing I am just curious, how are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.