Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force links sent by email to open in user's browser instead of gmail in-app browser

I have a website that is JavaScript-heavy and requires user to record their videos, When I send my emails to my customers the link opens in gmail's in-app browser which you cannot record from, Plus there's many functionalities missing.

How to trigger a popup when user clicks the links in the email to select whatever browser they wants instead of gmail's in-app one? I've seen some people do that I tried and did some research for it but not results.

like image 941
MMJ Avatar asked Jul 13 '20 07:07

MMJ


People also ask

How do I get email links to open in my browser?

On the right side of the URL's address bar, click on the icon depicting two intertwined diamonds, which show the handler menu. In the pop-up menu, select the option that reads, "Allow mail.google.com to open all links." From that point forward, all emails open in the browser of your choice.

How do I stop Gmail from opening links in Gmail?

In Gmail go to settings --) General, and uncheck the option to open links in gmail.


1 Answers

By default a web browsers cannot open a rival's web browser. This would be a security risk. There are hacks which involve the user downloading an add-on or extension. See answer in stackoverflow.com/questions/10070744/open-ie-browser-in-firefox-chrome-page

The popup you're referring to are most likely apps. The user would have to granted permission. (This I don't have experience with).

It looks like there is no way to programmatically force emails on Android to open in Chrome browser. The user has to alter their system settings. Therefore, an alternative approach may be to educate the user (about the loss of functionality). This can be done by preforming browser sniffing & displaying an appropriate message at the top of the webpage.

With JavaScript, you can test if a function is supported & enabled by creating functions. Below is an example, which determine is LocalStorage is available. (It's only for illustration purposes).

function isLocalStorageEnabled(){
    var test = 'test';
    try {
        localStorage.setItem(test, test);
        localStorage.removeItem(test);
        return true;
    } catch(e) {
        return false;
    }
}

if(isLocalStorageEnabled() === true){
    // available
}else{
    // unavailable
}

Also I believe there is no single way to detect if the user, is using Gmails built-in browser or Chrome. However based on the following factors, you can assume they're using Gmail if:

  • User has clicked an email link. (You can append a query string. On landing on site, store in session and redirect without the append query string).
  • User is on android (/Android/.test(window.navigator.userAgent)).
  • User is on Chrome (see answer stackoverflow.com/questions/4565112/javascript-how-to-find-out-if-the-user-browser-is-chrome/13348618#13348618).
  • The web browser doesn't support some sort of JavaScript function, which works on Chrome but not on Gmails browser.

If all criteria are true, then you can then display a message like: For full functionality, please use Chrome or alternatively in Gmail: Go to Settings, General, and uncheck the option to open links in gmail (and reopen link from Gmail).

Note: browser detection can be faked. However this should be fine for displaying messages.

like image 162
Greg Avatar answered Oct 05 '22 23:10

Greg