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

  • Home
  • SEARCH
  • 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 8813193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:47:04+00:00 2026-06-14T03:47:04+00:00

I know that the iPhone stops javascript from running when an app is sent

  • 0

I know that the iPhone stops javascript from running when an app is sent to the background (ie pressing the home button while the app is running), but I would like to be able to detect if this has happened when the javascript starts up again when the app is reactivated.

One solution I’ve been trying is to have an iterator constantly running to “check in” and then running a check against that to tell if the app has gone to background.

var lastCheckinTime = new Date().getTime();
function checkin(){
  lastCheckinTime = new Date().getTime();
}
setIterator( checkin, 1000 );

// Later, some code that needs to know if iphone went to background
var now = new Date().getTime();
if( (now - lastCheckinTime) > 1100 ) {
  // run sent to background code

Is there a better way to do this? The problem I’ve found with this method is that it doesn’t work if the user quickly closes and reopens the app, but I haven’t figured out a better way of detecting this yet.

  • 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-14T03:47:06+00:00Added an answer on June 14, 2026 at 3:47 am

    You can use the ‘pageshow’ event. Visit this page on your phone, http://jsfiddle.net/vbuDh/

    window.addEventListener('pageshow', function(ev){
    
        alert('dasd');
    
    },false);​
    

    This will fire anytime the tab gains focus, or mobile Safari is reactivated on this page.

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

Sidebar

Related Questions

I have an app that runs on iPad and iPhone running iOS 3.2, but
I know that after I have deployed my ipad/iphone app into App Store, it
hi all i want to know that while specifying url in my iphone native
I know that Phonegap has an event for back button, but it's only available
I've come from iPhone background and am writing an android app. I've got a
How can I know that my iPhone is connected to the Apple Push Notification
I'm taking CS193P iPhone Development courses, and even if.. I know that I'm pretty
I know that this sort of question has been asked here before, but still
I know that Java have its own garbage collection, but sometimes I want to
Does anyone know or have good links that explain what iPhone's event loop does

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.