一、首先找到public文件夹下的index
二、编辑代码
// gte判断IE7和IE7以上版本执行语句
<!--[if gte IE 7]> -->
<script>
//获取地址
var currentUrl = window.location.href;
window.onload = function () {
//单点登录参数
var index = currentUrl.indexOf("ticket");
if (index != -1) {
// 在 Vue 实例化之前调用 redirectToGoogleChrome 函数
redirectToGoogleChrome();
}
}
// 检测浏览器类型的函数
function getBrowserType() {
var userAgent = navigator.userAgent;
if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1) {
return "IE";
}
if (userAgent.indexOf("Trident") > -1) {
return "IE";
}
}
// 检测并跳转到谷歌浏览器的函数
function redirectToGoogleChrome() {
if (getBrowserType() === "IE") {
try {
var objShell = new ActiveXObject("WScript.Shell");
var x = getChromePath(objShell);
if (!x) {
alert('当前没有Chrome浏览器,请先安装Chrome浏览器');
} else {
var cmd = 'cmd /c "' + x + '\\chrome.exe" ' + currentUrl;
objShell.Run(cmd, 0, true);
window.opener = null;
window.open('', '_self');
window.close();
}
}
catch (e) {
}
}
}
//获取谷歌浏览位置
function getChromePath(objShell) {
var regPath = [
'HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome\\InstallLocation',
'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome\\InstallLocation',
'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome\\InstallLocation',
'HKEY_CURRENT_USER\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome\\InstallLocation',
'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\chrome.exe\\Path',
'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe\\Path',
];
// 判断是否安装谷歌浏览器
for (var i = 0; i < regPath.length; i++) {
try {
var x = objShell.regRead(regPath[i]);
if (x) {
return x;
}
} catch (e) { }
}
return undefined;
}
</script>
<!--<![endif] -->