Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Safari JavaScript Issues on iPad on with iOS6

I have an older HTML application that I am supporting, and admittedly, some of the JavaScript techniques are old, but I don't have the time to re-write the application at this time, it is 100,000's of lines of code.


A little background:

  • the code has been unchanged in several years
  • the code works on OSX (10.8.2) in Safari
  • the code works in Win 7 in Safari (5.1.7)


Unfortunately, several of my users have upgraded to iOS6 on the iPad and the code does not work in either Safari or Chrome.


The application will pop-up a window/tab based on the onChange event of a select element or from the onClick of a button.


The onClick from the button does not trigger the Safari "Allow Pop-up", but the onChange event does.


Once the pop-up window/tab has been opened (via one of the two methods above), the user makes a selection on screen and clicks a button which (ultimately) triggers a window.opener function.


I can not ever get the window.opener function to trigger when the pop-up window was triggered from the onChange (select element).


The window.opener will usually (maybe always, but I seem to remember it didn't once or twice) trigger if the pop-up window remains open, but the user manually puts focus on the "opener" window.


Again this works (and has worked) for many years on many different browser, unfortunatey, most of my users are now on iPads.


Any thoughts or tips would be greatly appreciated.


BTW first post, so please be kind.

iPad, iOS 6

Posted on Sep 25, 2012 8:17 AM

Reply
7 replies

Sep 25, 2012 5:36 PM in response to sparkyipad

With 100,000 lines of code in a web app, I don't think many people are going to be too interested. The best anyone could do is give general suggestions.


It sounds like you are opening a new window and then expecting something to happen on the opener in a timer. Because Safari on iOS only loads the current page, that timer isn't going to execute. Pop-ups are really a pain. If you were using CSS, you wouldn't have this problem.

Sep 26, 2012 7:00 AM in response to etresoft

Thank for looking at the post.


I guess my point of stating that it was 100,000's of lines is that I don't have the option of rewriting.


Given that, I was able to narrow the issue. The pop-up is not the issue, it can call the opener's function no problem, but the opener window's function has a setTimeout that is not triggered and that is the issue.


I'll try to post the sample and reproducible HTML again, this time with [ and ] instead of < and >, maybe that will let it go through.


parent.html:


[html] [head] [script language="JavaScript" type="text/javascript"] [!-- function callParentFromPopup() { console.log("start"); setTimeout(function() {callParent();}, 0); } function callParent() { console.log("finished"); } function newWindow() { return window.open("child.html","child"); } // --] [/script] [/head] [body] [form] [button type="button" onclick="newWindow();"]newWindow[/button] [/form] [/body] [/html]


child.html


[html] [head] [script language="JavaScript" type="text/javascript"] [!-- function updateOpener() { var cbf = "window.opener.callParentFromPopup"; eval(cbf + "();"); window.close(); } // --] [/script] [/head] [body] [form] [button type="button" onclick="updateOpener()"]updateOpener[/button] [/form] [/body] [/html]


Thanks!

Oct 10, 2012 12:57 AM in response to sparkyipad

Hey Sparkyipad, I had a problem just like yours. After using a touch-event the setTimeout wouldn't be triggerd. It did however trigger after a click-event. I've been googleing about this issues for about a day now and found a solution.


Aparently there's been some talk about a bug in the timer-functions in the new mobile safari when it was updated to IOS6 and this solution seems to work for me:

https://gist.github.com/3798925


In case you are wondering, this is were if found my answer:

https://github.com/mattbryson/TouchSwipe-Jquery-Plugin/issues/30#issuecomment-91 40015


Hope this helps

Safari JavaScript Issues on iPad on with iOS6

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.