How to prevent Facebook in app browser from opening my website links?

It is completely up to the user, there is no way to force opening it in the default browser instead. There is more information (and some answers) in this thread: File upload control not working in Facebook In-App Browser


I couldn't get my js dynamic grid to run in the Facebook in-app browser, but I couldn't just leave it up to the user to figure out what was wrong and that they needed to open in a real browser.

I used js to detect the Facebook in-app browser and tried using a js alert to inform the user that they needed to 'open in safari', but alerts don't work consistently or reliably with the Facebook in-app browser.

I found that a redirect to a user alert page was the most reliable solution. It can be presented as you wish (modal, etc.) A code sample for the redirect is included. Note that the redirect page remains within the Facebook browser - only user interaction can break out. I used my redirect page to tell people to use the 'share > open in Safari' function.

When the user clicks on 'open in safari', the redirect page reloads in safari, detects that it is now NOT in the Facebook in-app browser, and automatically redirects the user back to the page they wanted in the first place, but no longer from within the Facebook in-app browser. A "one-click" workaround to get the user out of that in-app browser.

The best solution would still be for my js grids to 'just work' in the Facebook browser some day. If anyone figures it out, let me know.

<!-- check if running in facebook app -->
    <script>

    var ua = navigator.userAgent || navigator.vendor || window.opera;

    function isFacebookApp() {
        return (ua.indexOf("FBAN") > -1) && (ua.indexOf("FBAV") > -1);
    }

    if (isFacebookApp()) {
        window.parent.location.assign("https://yourdomain.com/redirect_page/index.html");
    }

    </script>