Open a link to a website outside of the Facebook app

I've already found a way to detect if a page has been loaded inside a Facebook app, and it's done like this:

var ua = navigator.userAgent || navigator.vendor || window.opera;
if((ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1)) {
    var openInBrowser = window.confirm("This page works best outside of the Facebook app. Do you want to open it in your browser instead?");
    if (openInBrowser) {
        window.open(
          window.location.href, 
          '_blank'
        );
    }
}

      

However, this script doesn't seem to work. Is it because the phone is blocking it (popup blocker)? The goal is to ask the user to load the page through the browser, and if the user agrees, then open the page in Safari, Chrome, or any other browser.

+3
javascript facebook


source to share


No one has answered this question yet

See similar questions:

1
how to make links or pages open outside of facebook inapp browser?

or similar:

3953
What value of "href" should be used for JavaScript references, "#" or "javascript: void (0)"?
2329
How do I detect a click outside of an element?
1895
Open the url in a new tab (not a new window) using JavaScript
1571
How does Facebook disable built-in developer tools?
2
Facebook page link is open in facebook app instead of Safari browser
2
Enable Mobile Web App to open the link in the user's default mobile browser instead of opening it inside the app.
1
how to make links or pages open outside of facebook inapp browser?
1
Ios app: how to open a facebook link and ensure it opens in safari and not in the native app?
0
Facebook to enter the site, you must open it in the mobile application
-2
Opening the Facebook app outside of Facebook



All Articles
Loading...
X
Show
Funny
Dev
Pics