Hack Forums
[Javascript] Safari on iOS creates two confirm() boxes - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [Javascript] Safari on iOS creates two confirm() boxes (/showthread.php?tid=3987645)



Safari on iOS creates two confirm() boxes - Orgy - Jan 10, 2014

I'm trying to figure out how to solve it.

I came across this: http://stackoverflow.com/a/11546344/266542

Seems pretty simple for an alert() box, but how would I return the value of the confirm to the function that calls the setTimeout()?


* - Disease - Jan 11, 2014

(Jan 10, 2014 09:57 AM)Orgy Wrote:  I'm trying to figure out how to solve it.

I came across this: http://stackoverflow.com/a/11546344/266542

Seems pretty simple for an alert() box, but how would I return the value of the confirm to the function that calls the setTimeout()?

Declare the variable prior to the anonymous function.

Code
var userInput = false;

setTimeout(function () {
  userInput = confirm('Some prompt message');
}, 300);

Proof of concept:
[Image: 3ef92b9255d93c18bd38f1dcacbc9de1.png]


* - Orgy - Jan 11, 2014

(Jan 11, 2014 12:17 PM)Disease Wrote:  Declare the variable prior to the anonymous function.

Code
var userInput = false;

setTimeout(function () {
  userInput = confirm('Some prompt message');
}, 300);

Proof of concept:
[Image: 3ef92b9255d93c18bd38f1dcacbc9de1.png]

Ah hello Disease. I think I tried that at some point and it didn't work for some reason. I don't know. This code I've been fixing up is so terrible.

I'll try this out in a moment to see if it does indeed fix the bug.

Is there any other way to return it other than setting a variable above it's scope?

Come on Skype man