window.open
函数方法,该函数的作用是打开一个新窗口或改变原窗口,如果你直接在js中调用window.open()去打开一个新窗口,浏览器会拦截
setTimeout('window.open(url);', 500);# 点击这个超链接,浏览器会认为它是打开一个新的链接,就不会拦截。<a href="javascript:void(0)" onclick="window.open()"></a>
location.href

location.href ="https://www.oecom.cn";
采用a标签
export function openUrl(url, id = "default", type="_blank") {var a = document.createElement("a");a.setAttribute("href", url);a.setAttribute("target",type);a.setAttribute("id", id);// 防止反复添加if (!document.getElementById(id)) {document.body.appendChild(a);}a.click();}
兼容方案
var newTab=window.open('about:blank');newTab.location.href ="https://www.oecom.cn";
/*** @description: 在新标签页打开网页* @param {*} url 需要打开的url* @param {*} id 防止重复位置打开* @param {*} type 防止重复位置打开* @return {*}*/export function openUrl(url, id = "default", type="_blank") {let browser = myBrowser()if (browser === "Safari") {window.location = urlreturn}var a = document.createElement("a");a.setAttribute("href", url);a.setAttribute("target",type);a.setAttribute("id", id);// 防止反复添加if (!document.getElementById(id)) {document.body.appendChild(a);}a.click();}function IEVersion() {var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;if(isIE) {var reIE = new RegExp("MSIE (\\d+\\.\\d+);");reIE.test(userAgent);var fIEVersion = parseFloat(RegExp["$1"]);if(fIEVersion == 7) {return IE7;} else if(fIEVersion == 8) {return IE8;} else if(fIEVersion == 9) {return IE9;} else if(fIEVersion == 10) {return IE10;} else {return IE6;//IE版本<=7}} else if(isEdge) {return 'edge';//edge} else if(isIE11) {return IE11; //IE11}else{return -1;//不是ie浏览器}}function myBrowser() {var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器var ieVersion= IEVersion(); //判断是否IE浏览器var isEdge = userAgent.indexOf("Edge") > -1; //判断是否IE的Edge浏览器var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器var isSafari = userAgent.indexOf("Safari") > -1&& userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器var isChrome = userAgent.indexOf("Chrome") > -1&& userAgent.indexOf("Safari") > -1; //判断Chrome浏览器if (ieVersion !="-1") {return ieVersion;}if (isOpera) {return "Opera";}if (isEdge) {return "Edge";}if (isFF) {return "FF";}if (isSafari) {return "Safari";}if (isChrome) {return "Chrome";}}/*** @description: 解析url中的携带参数* @param {*} val* @return {*}*/export function parseQuery(val) {var params = {},seg = val.replace(/^\?/, '').split('&'),len = seg.length,p;for (var i = 0; i < len; i++) {if (seg[i]) {p = seg[i].split('=');params[p[0]] = p[1];}}return params;}
