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


source to share





All Articles