javascript <a> 标签打开相对路径,绝对路径

<a>标签中的href中,如果你写一个路径默认是以相对路径打开的,加上"http://" 消息头那就可以打开绝对路径

html:

<a href=javascript:void(0); target=_blank onclick=Common.openUrl("' + rowObject.baiduPanUrl + '")>' + cellvalue + '</a>'

js:

openUrl: function(url) {
            if (url.indexOf("http") != 0) {
                window.open("http://" + url);
            } else {
                window.open(url);
            }
        }
原文地址:https://www.cnblogs.com/leechenxiang/p/6674192.html