//js函數實現模擬a標簽的href
//創建a標簽,設置屬性,點擊
function js_a_href(){ var a = document.createElement('a'); a.setAttribute('href', 'http://www.XXX.com'); a.setAttribute('target', '_blank'); a.setAttribute('id', 'js_a'); //防止反復添加 if(document.getElementById('js_a')) { document.body.removeChild(document.getElementById('js_a')); } document.body.appendChild(a); a.click(); }
//或者隱藏一個a標簽,
<a href="http://www.XXX.com" id="hi_a" style="display:none;"></a>
function hidden_a_href(){
document.getElementById("hi_a").click();
}