Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Determine whether a URI scheme is enabled

Reply
Thread Tools

Determine whether a URI scheme is enabled

 
 
Chris Davies
Guest
Posts: n/a
 
      10-03-2007
I'm curious. I'd like to determine whether a particular URI scheme (the
"ftp:", "news:", "http:" part) is available within the user's browser.

For example, consider this HTML snippet:

Telephone us on <a href="tel:+44113393xxxx">0113 393-xxxx</a>

I could extend the tag with an onClick handler that displayed an
alert() box (or similar), but ideally I'd like it only to do that if
the underlying URI scheme couldn't be handled by the user's browser.

Thanks,
Chris
 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      10-03-2007
On Oct 3, 9:11 am, Chris Davies <(E-Mail Removed)> wrote:
> I'm curious. I'd like to determine whether a particular URI scheme (the
> "ftp:", "news:", "http:" part) is available within the user's browser.
>
> For example, consider this HTML snippet:
>
> Telephone us on <a href="tel:+44113393xxxx">0113 393-xxxx</a>
>
> I could extend the tag with an onClick handler that displayed an
> alert() box (or similar), but ideally I'd like it only to do that if
> the underlying URI scheme couldn't be handled by the user's browser.


You are out of luck there.

 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-03-2007
Chris Davies wrote:
> I'm curious. I'd like to determine whether a particular URI scheme (the
> "ftp:", "news:", "http:" part) is available within the user's browser.
>
> I could extend the tag with an onClick handler that displayed an alert()
> box (or similar), but ideally I'd like it only to do that if the underlying
> URI scheme couldn't be handled by the user's browser.


You can do something along

function navigateTo(s)
{
try
{
window.location = s;
}
catch (e)
{
window.alert("Unsupported URI scheme: " + s.match(/^[^:]+/));
}

return false;
}

<a href="foo:bar" onclick="return navigateTo(this.href);">...</a>

But you can't suppress an error message displayed by the UA already.


PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
 
Reply With Quote
 
Chris Davies
Guest
Posts: n/a
 
      10-05-2007
Chris Davies wrote:
> I'm curious. I'd like to determine whether a particular URI scheme (the
> "ftp:", "news:", "http:" part) is available within the user's browser.


Thomas 'PointedEars' Lahn <(E-Mail Removed)> wrote:
> You can do something along


> function navigateTo(s)
> {
> try
> {
> window.location = s;
> }
> catch (e)
> {
> window.alert("Unsupported URI scheme: " + s.match(/^[^:]+/));
> }


In FF the "No program for this URI scheme" error (paraphrased) can't be
caught like this, so sadly I'm no better off.

Thanks for the thought.
Chris
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-05-2007
Chris Davies wrote:
> Chris Davies wrote:
>> I'm curious. I'd like to determine whether a particular URI scheme (the
>> "ftp:", "news:", "http:" part) is available within the user's browser.

>
> Thomas 'PointedEars' Lahn <(E-Mail Removed)> wrote:
>> You can do something along

>


Please read the FAQ on how to quote correctly in Usenet.

>> function navigateTo(s)
>> {
>> try
>> {
>> window.location = s;
>> }
>> catch (e)
>> {
>> window.alert("Unsupported URI scheme: " + s.match(/^[^:]+/));
>> }

>
> In FF the "No program for this URI scheme" error (paraphrased) can't be
> caught like this,


It can be considered a great advantage here to be capable of reading.

| But you can't suppress an error message displayed by the UA already.

> so sadly I'm no better off.


As I said: you can't do this.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open a file designated with file uri scheme Jerry Fleming C Programming 3 12-02-2010 02:29 AM
java.net.URI.relativize(java.net.URI) not really working Stanimir Stamenkov Java 1 08-17-2005 06:24 PM
Help with error: "Invalid URI: The format of the URI could not be determined." Simon Harris ASP .Net 0 05-10-2005 04:33 PM
Re: XSLT: Relative URI "my.dtd" can not be resolved without a base URI etheriau XML 1 08-23-2004 01:54 PM
XSLT: Relative URI "my.dtd" can not be resolved without a base URI Pavel XML 2 08-03-2004 11:40 PM



Advertisments