onFBShare() test

delay load the FB URL in another browser tab; try to trigger the FB mobile app to load

by Chris Vitalos

JavaScript

function isMobile(m, d) {
      const ua = navigator.userAgent;
      const platform = navigator.platform;
      if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(ua) ||
        (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(platform))) 
        { // if test true for mobile browser, execute m()
          console.log("this is a mobile browser");
          if (typeof e === "function") {
            m();
          }
          return true; //  return true
        } else { // If test false, execute d()
          console.log("this is a desktop browser");
          if (typeof d === "function") {
            d();
          }
          return false; // return false
        }
      }

      function onFBshare() {
        isMobile(function() {
          window.location = "fb://page/102012525593732";
        }, function() {
          setTimeout(function() {
            window.location = "https://www.facebook.com/SaveRRP";
          }, 25);
        })
      }