Richard Maher
5/31/2015 5:12:00 AM
On 5/21/2015 6:10 AM, Richard Maher wrote:
> On 5/20/2015 5:08 AM, Michael Haufe (TNO) wrote:
>>
>> I've found something slightly productive in Firefox:
>>
>> Set up an iframe: <iframe src="about:blank"></iframe>
>
> I'll have a look at your iframe idea.
>
> Unfortunately phone-based Chrome, Firefox, and the Android browser all
> trigger the beforeunload event before invoking the phone :-(
>
> Safari on an iPad (without a phone) asks you to confirm +12345 Call/Cancel.
>
> I guess they really don't want you to discobver if there is a phone there.
>
Hi Michael,
The good news about your iFrame strategy is at least we can achieve
uniformity with silent failures to CALL/MAIL.
What I have done in the code below is demonstrate how to receive one
(and only one FireFox what a nightmare! preventDefault() is anti-logic)
BeforeUnload event when an attempt is made to phone/mail. )Opera
provides additional failure ALERT)
I'm guessing, (will try now) that I can wait N secs after the
beforeunload event and if it hasn't been cancelled by my
VisibilityChange event on the main window then that protocol is not
supported. Good enough?
Cheers Richard
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
iframe
{
display: none;
width: 0px;
height: 0px;
}
</style>
</head>
<body onunload="console.log('Bye');" onblur="console.log('*blur');"
onload="load();">
<a id="anchor" href="#" target="output" onclick="myFunction()">
<button >Replace document</button>
</a>
<div id="fred"></div>
<script>
var cnt = 0;
var myW, out;
function load() {
document.addEventListener("visibilitychange", vc);
out = document.createElement("iframe");
out.addEventListener("load",fLoad);
out.name = "output";
out.src = "about:blank"
document.body.appendChild(out);
}
function vc() {
cnt++;
document.getElementById("fred").innerHTML="Visibility change"+cnt;
}
function fLoad() {
out.contentWindow.addEventListener("unload",fUnLoad);
out.contentWindow.addEventListener("beforeunload",fBeforeUnLoad);
console.log("*loaded");
}
function fUnLoad() {
out.contentWindow.removeEventListener("unload",fUnLoad);
setTimeout(resetx, 0);
console.log("*unloaded");
}
function resetx() {
out.src = "about:blank"
}
function fBeforeUnLoad(e) {
out.contentWindow.removeEventListener("beforeunload",fBeforeUnLoad);
setTimeout(reAdd, 0);
console.log("*beforeunload");
return;
}
function reAdd(){
out.contentWindow.addEventListener("beforeunload",fBeforeUnLoad);
}
function hndlr(e) {
var msg = "Cannot make calls message\ncurrentTraget =
"+e.currentTarget.location+"\ntarget = "+e.target.URL;
(e || window.event).preventDefault();
return;
(e || window.event).returnValue = msg;
return msg;
}
function myFunction() {
try{
document.getElementById("anchor").href="tel:+61123";
return;
} catch (e) {alert("e is "+e);}
}
</script>
</body>
</html>