Solved

setTimeout doesn't work on iPad using Safari

Posted on 2013-06-06
9
3,733 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i Return this word's max repeat count? 2 21
jqury 17 30
Adding Row and Cell on a table 14 20
Jquery 2 14
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

825 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