Javascript 浏览器重定向Vuetify Vue.js应用程序(如果是IE11或IE10)
我在Vuetify和IE11上经历了一场噩梦,我想重定向到一个基本的HTML页面,上面说不支持IE11或IE10。我在一所大学工作,IE11仍然是标准,因为它与我们的电子病历系统紧密结合。IE11是标准,因此,如果在电子邮件中发送链接,IE11将打开。我已在app.vue页面中进行了尝试Javascript 浏览器重定向Vuetify Vue.js应用程序(如果是IE11或IE10),javascript,vue.js,internet-explorer-11,vuetify.js,Javascript,Vue.js,Internet Explorer 11,Vuetify.js,我在Vuetify和IE11上经历了一场噩梦,我想重定向到一个基本的HTML页面,上面说不支持IE11或IE10。我在一所大学工作,IE11仍然是标准,因为它与我们的电子病历系统紧密结合。IE11是标准,因此,如果在电子邮件中发送链接,IE11将打开。我已在app.vue页面中进行了尝试 var compatibleBrowser = typeof Object["__defineSetter__"] === "function"; if (compa
var compatibleBrowser = typeof Object["__defineSetter__"] === "function";
if (compatibleBrowser == false) {
alert("Sorry, this is not a compatible browser.");
}
及
Stackoverflow和Codepen都有一些识别代码,我想将其添加到vue应用程序中。问题是我经常看到SCRIPT5009:“Symbol”是未定义的文件:vuetify.js,行:19641,列:1
我似乎无法用多填充物来修复它
因此,下一个最好的方法是重定向您可以检测浏览器版本,然后IE是否会呈现一些您需要的消息。如果不是IE,则渲染vue应用程序 我在public/index.html中使用JavaScript检测浏览器,代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>my-vue-app</title>
</head>
<body>
<noscript>
<strong>We're sorry but my-vue-app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<!-- built files will be auto injected -->
<script type="text/javascript">
function get_browser() {
var ua = navigator.userAgent, tem, M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if (/trident/i.test(M[1])) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return { name: 'IE', version: (tem[1] || '') };
}
if (M[1] === 'Chrome') {
tem = ua.match(/\bOPR\/(\d+)/)
if (tem != null) { return { name: 'Opera', version: tem[1] }; }
}
if (window.navigator.userAgent.indexOf("Edge") > -1) {
tem = ua.match(/\Edge\/(\d+)/)
if (tem != null) { return { name: 'Edge', version: tem[1] }; }
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+)/i)) != null) { M.splice(1, 1, tem[1]); }
return {
name: M[0],
version: +M[1]
};
}
var browser = get_browser()
var isSupported = isSupported(browser);
function isSupported(browser) {
var supported = false;
if (browser.name === "Chrome" && browser.version >= 48) {
supported = true;
} else if ((browser.name === "MSIE" || browser.name === "IE") && browser.version <= 11) {
supported = false;
} else if (browser.name === "Edge") {
supported = true;
}
return supported;
}
if (!isSupported) {
//render unsupported message
document.write("<h1>The app is not supported in IE. Please use other browsers!</h1>");
}
else{
//render app
var elem = document.createElement("div");
elem.setAttribute("id", "app")
document.body.appendChild(elem);
}
</script>
</body>
</html>
我的vue应用程序
很抱歉,如果没有启用JavaScript,我的vue应用程序无法正常工作。请使其继续。
函数get_browser(){
var ua=navigator.userAgent,tem,M=ua.match(/(opera | chrome | safari | firefox | msie | trident(?=\/)\/?\s*(\d+)/i)| |【】;
if(/trident/i.test(M[1])){
tem=/\brv[:]+(\d+)/g.exec(ua)| |[];
返回{name:'IE',version:(tem[1]| |“”);
}
如果(M[1]=='Chrome'){
tem=ua.match(/\bOPR\/(\d+/)
如果(tem!=null){return{name:'Opera',version:tem[1]};}
}
if(window.navigator.userAgent.indexOf(“边缘”)>-1){
tem=ua.match(/\Edge\/(\d+)/)
如果(tem!=null){返回{name:'Edge',version:tem[1]};}
}
M=M[2]?[M[1],M[2]]:[navigator.appName,navigator.appVersion',-?';
如果((tem=ua.match(/version\/(\d+)/i))!=null){M.splice(1,1,tem[1]);}
返回{
名称:M[0],
版本:+M[1]
};
}
var browser=get_browser()
var isSupported=isSupported(浏览器);
支持的功能(浏览器){
支持的var=false;
如果(browser.name==“Chrome”&&browser.version>=48){
支持=正确;
}否则如果((browser.name==“MSIE”| | browser.name==“IE”)&&browser.version在index.html中的哪个位置检查浏览器类型?它必须在vue接管该页面上唯一的脚本标记之前完成,并且它是唯一的代码-谢谢
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>my-vue-app</title>
</head>
<body>
<noscript>
<strong>We're sorry but my-vue-app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<!-- built files will be auto injected -->
<script type="text/javascript">
function get_browser() {
var ua = navigator.userAgent, tem, M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if (/trident/i.test(M[1])) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return { name: 'IE', version: (tem[1] || '') };
}
if (M[1] === 'Chrome') {
tem = ua.match(/\bOPR\/(\d+)/)
if (tem != null) { return { name: 'Opera', version: tem[1] }; }
}
if (window.navigator.userAgent.indexOf("Edge") > -1) {
tem = ua.match(/\Edge\/(\d+)/)
if (tem != null) { return { name: 'Edge', version: tem[1] }; }
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+)/i)) != null) { M.splice(1, 1, tem[1]); }
return {
name: M[0],
version: +M[1]
};
}
var browser = get_browser()
var isSupported = isSupported(browser);
function isSupported(browser) {
var supported = false;
if (browser.name === "Chrome" && browser.version >= 48) {
supported = true;
} else if ((browser.name === "MSIE" || browser.name === "IE") && browser.version <= 11) {
supported = false;
} else if (browser.name === "Edge") {
supported = true;
}
return supported;
}
if (!isSupported) {
//render unsupported message
document.write("<h1>The app is not supported in IE. Please use other browsers!</h1>");
}
else{
//render app
var elem = document.createElement("div");
elem.setAttribute("id", "app")
document.body.appendChild(elem);
}
</script>
</body>
</html>