0

I'm looking for a very simple piece of code that will check if a website user is browsing with the facebook in-app browser. I was able to produce a very simple piece of code to check for safari users. I'm hoping I can find something just as clean and simple for the facebook in-app browser.

Kind of like this:

JS

var isSafari = window.safari !== undefined;

function checkbrowser() {
    if (isSafari) {
        alert('safari incompatibility warning');
    }
}
Kaylub
  • 91
  • 1
  • 8
  • 1
    Check `navigator.appName` or look at the request headers. – Scott Marcus Jul 09 '17 at 21:25
  • How would I do that? – Kaylub Jul 09 '17 at 21:26
  • 1
    @ScottMarcus `navigator.appName` cannot be used for this. The Facebook app returns "Netscape". User agent Strings may change over time, but so far I have been using this: `var isFbInAppBrowser = navigator.userAgent.indexOf('FBAV') > -1;` _("FBAV" stands for "FaceBook App Version")_ – blex Jul 09 '17 at 21:39
  • Yea, that's kind of why I was asking. Every browser I checked returned navigator.appName as "Netscape". I'll try this var check out right now. – Kaylub Jul 09 '17 at 21:43
  • @blex That totally did the trick. Thanks! – Kaylub Jul 10 '17 at 00:20
  • so what is the answer here? I need to trigger a Jquery Mobile pop up if the user enters from the facebook browser. Facebook doesn't allow any geolocation so i need to make a special function for this case. –  Jul 12 '17 at 16:11
  • Possible duplicate of [How to detect Facebook in-app browser?](https://stackoverflow.com/questions/31569518/how-to-detect-facebook-in-app-browser) –  Jul 12 '17 at 16:21

0 Answers0