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);
            }
        }

 

posted @ 2017-04-06 16:41  风间影月  阅读(5676)  评论(0编辑  收藏  举报