12

Possible Duplicate:
iPhone Safari: check if URL scheme is supported in javascript?

I'm using pic2shop to provide barcode scanning for a mobile web app. For iOS, one can check [canOpenURL] to see if a particular scheme is valid (tel://, pic2shop://). Is there anything in mobile browsers (iOS, Android, etc) that provides the same functionality?

Community
  • 1
  • 1
mikhuang
  • 2,694
  • 2
  • 19
  • 17
  • 2
    I've noticed that a similar question was answered here: http://stackoverflow.com/questions/627916/iphone-safari-check-if-url-scheme-is-supported-in-javascript . Is this still the case or has Mobile Safari changed? – mikhuang May 19 '11 at 22:16

1 Answers1

1

You may try placing that URL in an iframe and wait for some seconds. If you are not being redirected to an app, it means that it's not registered.

setTimeout(function() {
  alert('It seems that your device does not support our feature.');
}, 1000);

document.write('<iframe style="border:none; width:1px; height:1px;" src="pic2shop://"></iframe>');
iwat
  • 3,591
  • 2
  • 20
  • 24
  • 4
    Note that if this fails it shows alert with the message "Safari cannot open the page because the address is invalid." – Erik Rothoff Apr 12 '12 at 13:44