0

Possible Duplicate:
iPhone Safari: check if URL scheme is supported in javascript?
How to check if a custom protocol supported

Facebook registers the URI scheme fb:// when someone installs the Facebook app on their iPhone or iPad. Any links with fb:// will only work if the Facebook app is installed, otherwise Mobile Safari reports it doesn't know how to open the page.

Is it possible to use JavaScript/jQuery to see if Mobile Safari cannot open the page and then replace the link with a web link instead of the app link? Basically I want to use JavaScript to see if the Facebook app is installed on their phone. I'd like the solution to work on Android as well.

enter image description here

Community
  • 1
  • 1
Kirk Ouimet
  • 27,280
  • 43
  • 127
  • 177

1 Answers1

0

You could probably find a function in the FB script, then create a function in your own script to check if that function is defined or not.

if(typeof(facebook.function)=='undefined') { 
   //replace something 
} else {  
   //move along 
}

Then you run that function when someone clicks a link, either moving along or replace the link before moving along, you could even use a timed loop if it's undefined to give it a second in case it needs to load something.

This will take some testing to see what you can use from the Facebook script, but should be straight forward as all you need to do is test some functions and see if they return as function when the script is loaded and as undefined when the script is not loaded.

adeneo
  • 312,895
  • 29
  • 395
  • 388