2017-11-18 41 views
0

我在我的函數中都有href和onclick事件。使用Javascript打開新選項卡:FunctionName href

Onclick我有代碼naviage到perticuar頁面。當我點擊打開新標籤時,它會打開一個關於:空白的鏈接。

你能幫我點什麼嗎?

以下是我的代碼。

<a href="javascript:void(0);" id="help" onclick="javascript:GoToURL('/html/mystats.cfm')" >Test </a>

+0

可能的複製(https://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-and-not-a-new-window-using-javascript) – caramba

+1

爲什麼不直接設置'href'到url並使用'target '屬性如果你想打開它在一個新的標籤'target =「_ blank」'?我沒有看到使用'javascript'並編寫一個函數來完成錨標籤旨在處理/處理的內容。 – NewToJS

回答

0
<a href="javascript:void(0);" onclick="window.open('https://www.example.com', '_blank'); ">Test</a>

[使用JavaScript中打開新的標籤頁的URL(而不是一個新窗口)]的
相關問題