2013-07-05 129 views
0

此代碼工作正常新窗口..自動點擊鼠標懸停在

<a href="http://google.com/" onmouseover="window.location=this.href">Text</a> 

但我需要在新標籤頁中打開鏈接

+0

等待。 onmouseover導航到新頁面?似乎是一種奇怪的用戶體驗(UX)。觸摸設備不支持'onmouseover'。 – Raptor

+0

[JavaScript:location.href可能在新窗口/標籤中打開?](http://stackoverflow.com/questions/5141910/javascript-location-href-to-open-in-new-window-tab) – Raptor

+0

做一些谷歌搜索的朋友 有很多的答案,這已經 –

回答

1

而不是使用window.location的,你可以使用:

window.open('http://www.google.com', '_blank'); 

將在新窗口中打開。

+0

window.open('google.com','_blank'); .....在新窗口中打開,但我需要在新標籤中不是新窗口! – Ahmed

+0

閱讀此:http://stackoverflow.com/a/4907854/188331。沒有腳本可以控制新內容在新標籤頁/新窗口中打開。取決於瀏覽器設置! – Raptor

0

您可以使用它。但新窗口

<a href="#" onmouseover="javascript:window.open('http://google.com')">Text</a> 

或使用JavaScript。 This 新標籤

<a href="#" onmouseover="myFunction()">Text</a> 
<script> 
function myFunction() { 
    var Open = window.open("http://www.kangsigit.com", "_blank"); 
} 
</script>