Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27933

Re: Javascript TEL: URI support detection

From Richard Maher <maher_rjSPAMLESS@hotmail.com>
Newsgroups comp.lang.javascript
Subject Re: Javascript TEL: URI support detection
Date 2015-05-31 13:12 +0800
Organization Aioe.org NNTP Server
Message-ID <mke57c$704$1@speranza.aioe.org> (permalink)
References (2 earlier) <mjcgc2$ce6$1@speranza.aioe.org> <c70f6439-f287-417c-acd8-8dfdd60be9e2@googlegroups.com> <mjfct8$72e$1@speranza.aioe.org> <29aba100-f272-4521-bd35-67ac75089118@googlegroups.com> <mjj0oh$kqa$1@speranza.aioe.org>

Show all headers | View raw


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>

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-05-17 16:32 +0800
  Re: Javascript TEL: URI support detection "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-17 11:32 +0200
    Re: Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-05-17 19:12 +0800
      Re: Javascript TEL: URI support detection Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-19 21:59 +0200
  Re: Javascript TEL: URI support detection "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-05-17 22:01 -0700
    Re: Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-05-18 18:53 +0800
      Re: Javascript TEL: URI support detection "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-05-18 08:53 -0700
        Re: Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-05-19 21:13 +0800
          Re: Javascript TEL: URI support detection "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-05-19 14:08 -0700
            Re: Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-05-21 06:10 +0800
              Re: Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-05-31 13:12 +0800
                Re: Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-06-01 18:52 +0800
                Re: Javascript TEL: URI support detection "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-06-10 18:49 -0700
                Re: Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-06-13 08:15 +0800
                Re: Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-06-22 06:07 +0800
                Re: Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-06-22 06:08 +0800
                Re: Javascript TEL: URI support detection "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-06-24 14:09 -0700
                Re: Javascript TEL: URI support detection Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-06-25 18:54 +0800
                Re: Javascript TEL: URI support detection "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-06-25 06:40 -0700
                Re: Javascript TEL: URI support detection ittsmith1@gmail.com - 2015-07-20 18:57 -0700

csiph-web