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 8339921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:01:08+00:00 2026-06-09T05:01:08+00:00

I am putting together a jquery mobile site that includes several separate pages (*.htm)

  • 0

I am putting together a jquery mobile site that includes several separate pages (*.htm) for webcams. On those page, I am loading a set interval function that refreshes the image grab from the camera every few seconds and simulates video.

The problem occurs however when I navigate away from the webcam page (webcam.htm) using a nav link or back button back to index.htm, the webcam.htm page remains in the DOM and keeps pulling the images every few seconds.

How can I clear the page or at least endinterval when the user leaves?

<script type="text/javascript">
    function camfresh() {
        setInterval(function(){ $("#rmcam").attr("src", "image.jpg?"+new Date().getTime());},2000);
    }
</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-09T05:01:10+00:00Added an answer on June 9, 2026 at 5:01 am

    You can use the pageshow and pagehide events to start and stop the interval:

    var myInterval;
    $(document).delegate('.ui-page', 'pageshow', function () {
    
        //note that `this` refers to the current `data-role="page"` element
    
        //cache `this` for later (inside the setInterval anonymous function)
        var $this = $(this);
    
        myInterval = setInterval(function(){
            $this.find("#rmcam").attr("src", "image.jpg?"+new Date().getTime());
        }, 2000);
    }).delegate('.ui-page', 'pagehide', function () {
        clearInterval(myInterval);
    });
    

    You can change the .ui-page selectors to be more specific (currently they will select every pseudo-page).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm putting together a fixed, one-page site that deploys an overlay using jQuery. There
I'm putting together a simple web page that presents the user with a jQuery
I putting together a page that will display a set of stored values. I
I am currently putting together some jQuery that will activate slideDown() when an element
I am putting together a fairly simple web app that uses user inputted data
I am putting together a technical analysis library that I hope others may use
I'm putting together some demo pages, and one of the things I want to
I'm putting together an image gallery for an ecommerce site and wanting to use
I am totally stumped on this. I am putting together a script that checks
For putting together a site from scratch, what are the advantages and disadvantages of

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.