Jump to content

Scheme detection


boen_robot

Recommended Posts

Is there any way I could detect if a browser supports a certain scheme (say, "tel" for example)?I'm only assuming that if there's a way, it would be with PHP (or another S3L), but I have no clue if it's possible to begin with, so if it is, I'm opened to anything it might involve... as long as it's not just "browser detection" but a "scheme detection".

Link to comment
Share on other sites

You could try putting some test code in a try/catch block in Javascript and see if it executes. All you could do with PHP is look up the browser using a browscap file using the get_browser function, but that doesn't give any information about which protocols or schemes the browser supports.

Link to comment
Share on other sites

You could try putting some test code in a try/catch block in Javascript and see if it executes. All you could do with PHP is look up the browser using a browscap file using the get_browser function, but that doesn't give any information about which protocols or schemes the browser supports.
What sort of code would that be for the "tel" scheme?
Link to comment
Share on other sites

Try to send a request using the scheme. You might be able to try to load a test object with a URL using that scheme, I'm not sure how to force Javascript to send a request using a non-HTTP scheme.
How would I check the output in a scheme as obscured as "tel" or "mailto" for example (which I wouldn't test for, since virtually all browsers support it).
Link to comment
Share on other sites

I don't know of a way other then to attempt to make a request and check for an error or exception. The presence of an error won't automatically mean that the browser doesn't support the scheme, but it's a start.
Ahh... I see... check for a failure, not for success.The only problem left is how to send a request on an arbitary scheme, ideally without requiring a new window to be opened.
Link to comment
Share on other sites

Right. You might be able to use Javascript to create an image object and set the src of it using the scheme you want to test. I'm pretty sure the XMLHttpRequest object only deals with HTTP, so you would have to use something where you can specify which protocol or scheme to use.I'm not sure how you would test for something like the browser support mailto though. You almost just have to tell people that the link might not work, or give them examples of which browsers would support it or what they need.

Link to comment
Share on other sites

Right. You might be able to use Javascript to create an image object and set the src of it using the scheme you want to test.
How would I check if the request failed in this case? Is there a JS object for that?
I'm pretty sure the XMLHttpRequest object only deals with HTTP, so you would have to use something where you can specify which protocol or scheme to use.
I think I can do it with window.open(), but in this case, the focus moves to the new window. I mean, all events from the old window seem to be halt. How would I check if the call failed if I use that?
I'm not sure how you would test for something like the browser support mailto though. You almost just have to tell people that the link might not work, or give them examples of which browsers would support it or what they need.
A human readable documentation. Sure. That's always something and it's what I'll be stuck with using if there isn't any way this could be done.
Link to comment
Share on other sites

Yeah, unfortunately this just isn't a very easy thing to do. To test for failure, I usually use a try/catch block.

support = true;try{  imageObj.src = "tel://...";}catch (err){  support = false;}

I just don't know if that would work with a scheme though.I found this from the RFC for a scheme called vemmi:

When a Web browser encounters a VEMMI URL without having VEMMI support, two cases may occur: - some browsers will detect an unrecognized scheme and signal an unrecoverable error directly. - others will manage it as a relative URL [4] and will build a complete URL including the VEMMI URL and will request it from the host having sent the current document. In this case the host will usually return the error "not found".Among the mechanisms that could be used in order to offer a friendly interface to both users with and without VEMMI support: - when the second case occurs and the relative URL including the vemmi:// string is transmitted to the server, the HTTPD server may be modified in order to recognize such URL and to propose the downloading of a VEMMI client software. - the HTML document including the vemmi URL allowing to start the VEMMI session may propose both options, for example: If your browser supports VEMMI, directly <A HREF="vemmi://ares.mctel.fr/TEST">start the interactive multimedia service</A>, otherwise <A HREF="ftp://ftp.mctel.fr/vemmi.exe">download first a VEMMI client software</A>. - the application/vemmi MIME type is defined below (to allow for example exchange of vemmi objects). A possible way is for the server to look in the HTTP Accept header field and to deduce that if application/vemmi is supported, then the VEMMI support exists (in this case, application/vemmi is to be defined in the browser and associated with the vemmi decoder).
You should probably set up a test page where you can test what a browser does when it finds a scheme it doesn't support. IE at least gives you an event that fires whenever an error occurs, you can use that in your testing.http://msdn2.microsoft.com/en-us/library/ms976144.aspx
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...