先获取a标签,加入获取到后取名叫a, a.setAttribute('target','')最后一个参数设置target属性值。
var a = document.getElementById("a_link_id");// 通过id获取对象a.href = "www.baidu.com";a.setAttribute("onclick",'');a.setAttribute("target",'_blank');a.click("return false");