Solved

setTimeout doesn't work on iPad using Safari

Posted on 2013-06-06
9
3,673 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now