Vue page browser judgment

pages written by vue, ie and other browsers are not compatible. How to determine the browser when opening the first page and prompt the user to use the chrome browser to access it? Thank you!

Mar.04,2021

    var userAgent = navigator.userAgent; //userAgent
    var isOpera = userAgent.indexOf("Opera") > -1;
    if (isOpera) {
        return "Opera"
    }; //Opera
    if (userAgent.indexOf("Firefox") > -1) {
        return "FF";
    } //Firefox
    if (userAgent.indexOf("Chrome") > -1){
  return "Chrome";
 }
    if (userAgent.indexOf("Safari") > -1) {
        return "Safari";
    } //Safari
    if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
        return "IE";
    }; //IE
}

//
var mb = myBrowser();
if ("IE" == mb) {
    alert(" IE");
    
    // 
}

index.html page


html :
 <p v-if="isShowChromeTip" style="color: red;font-size: 15px; margin-top: -30px;text-align:center">Chrome<a target="_blank" href="https://www.baidu.com/link?url=AAazRp3jmfLLZ4bMb1jamhnrWvxDBE3D5-P0NA6YIKM9e0XTc3kUvA7kJK6OdK7S3T_jFDV2VTTsvKnGB6DDto3CfN5FDBEJfFTgkXBu2DS&wd=&eqid=a35565a60002e3ea000000035a13f001"></a>

script computed: { isShowChromeTip() { const USER_AGENT = navigator.userAgent.toLowerCase() const isChrome = /.*(chrome)\/([\w.]+).*/ return !isChrome.test(USER_AGENT) } }

or add the added polyfill

inside App.vue:

<script>
import "babel-polyfill";
export default {
  name: "app"
};
</script>


refer to the MDN document: example _ 1: detect the browser and return the browser name string

var sBrowser, sUsrAg = navigator.userAgent;

// The order matters here, and this may report false positives for unlisted browsers.

if (sUsrAg.indexOf("Firefox") > -1) {
  sBrowser = "Mozilla Firefox";
  // "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0"
} else if (sUsrAg.indexOf("Opera") > -1 || sUsrAg.indexOf("OPR") > -1) {
  sBrowser = "Opera";
  //"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 OPR/57.0.3098.106"
} else if (sUsrAg.indexOf("Trident") > -1) {
  sBrowser = "Microsoft Internet Explorer";
  // "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Zoom 3.6.0; wbx 1.0.0; rv:11.0) like Gecko"
} else if (sUsrAg.indexOf("Edge") > -1) {
  sBrowser = "Microsoft Edge";
  // "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"
} else if (sUsrAg.indexOf("Chrome") > -1) {
  sBrowser = "Google Chrome or Chromium";
  // "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
} else if (sUsrAg.indexOf("Safari") > -1) {
  sBrowser = "Apple Safari";
  // "Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1 980x1306"
} else {
  sBrowser = "unknown";
}

alert(": " + sBrowser);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5d271-456fa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5d271-456fa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?