?
Solved

setTimeout doesn't work on iPad using Safari

Posted on 2013-06-06
9
Medium Priority
?
4,269 Views
Last Modified: 2013-11-29
We have a web app that uses setTimeout to blank out the screen after 15 minutes of non use. It's a medical application so this is an important feature.  It works fine in every browser except Safari on a mobile device (ipad, etc).

The original code was as follows:

setTimeout("WindowClose()",900000);
function Windowclose() {
     parent.main.location.href = "/cgi-bin/screensaver.cgi";
}

This works fine except on the ipad.

I scanned the Net and found this as a solution which works, but also not on the ipad.

sTimeout = setTimeout(function() {
   parent.main.location.href="/cgi-bin/screensaver.cgi";
}.bind(this),900000);

setTimeout.prototype.bind = function(parent) {
   var f = this;
   var args = [];

   for (var a = 1; a < arguments.length; a++) {
       args[args.length] = arguments[a];
   }

   var temp = function() {
      return f.apply(parent, args);
   }

   return(temp);
}


That works fine everywhere else except again on the iPad.

Does anyone have an example of some working code for the iPad or tell what's wrong with what I'm doing?
0
Comment
Question by:geekdad1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 22

Expert Comment

by:Kim Walker
ID: 39227057
What does screensaver.cgi do? Is the setTimeout not executing or is screensaver.cgi not working?
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 39227125
I also have not been able to find any documentation regarding the "main" property of the parent document. What are you expecting to reference by "parent.main".

Why is it necessary for you to reference the parent document. Is this being executed from an embedded iframe?

When you say "everywhere but the iPad" does that mean it works on other Apple products such as laptops and desktop computers running MacOS?

I'm afraid there isn't enough information here to offer any suggestions.
0
 
LVL 1

Author Comment

by:geekdad1
ID: 39227191
Screensaver.cgi  just replaces the page in the main frame with a page that requires a password to continue.

It's not an iframe just a regular frame.  The frame is called main hence the parent.main reference.

The initial code (and for that matter the newer more complicated version) works, with IE, Firefox, Safari on windows and MacOS.  The only version that it doesn't work on is Safari on a mobile platform.  (iPad, iPhone, etc).

It would appear the setTimeout is not working.  Screensaver.cgi is never called.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 22

Expert Comment

by:Kim Walker
ID: 39227238
So you're using frames and framesets? Are you using the frameset doctype?

Have you determined whether the setTimeout is not executing or if the code being executed is generating an error?
0
 
LVL 1

Author Comment

by:geekdad1
ID: 39227299
I changed the function to issue an alert instead of trying to change the frame document.  No alert message was displayed.  So I have to assume the setTimeout code is not executing.
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 39227441
It appears to be a known bug. I found this in an internet search.
0
 
LVL 1

Accepted Solution

by:
geekdad1 earned 0 total points
ID: 39230432
The problem turns out to be related to whether it's an http site, or an https site.
setTimeout works on http sites, but doesn't work on https sites.

I guess I'll have to report this to the safari people for resolution.
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Several part series to implement Internet Explorer 11 Enterprise Mode
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question