[英]Hide URL of mouse overing link
更新
<font onclick="window.open('https://www.google.pt/', '_self');" style="background:0;border:0;outline:0">Link
我必須使用標簽將事件添加到文本,所以我使用了font
因為它不會進行任何修改。 PS:這在JS Fiddle上不起作用,因為某種原因,它無法打開鏈接(保持空白)。
<a href="https://www.google.pt/">Google</a> <br> When I over the mouse on the link, it shows the URL on the bottom left corner. <br> <img src="http://i.imgur.com/pq3ket7.png"> <br> Is there any way to prevent it? I'm using Chrome.
這是不受控制的瀏覽器行為。
您可以將其轉換為div,將click事件偵聽器附加到回調函數中打開所需的URL。
JSFiddle壞了,所以我將所有代碼粘貼到這里。 請注意,這些鏈接在JSFiddle中不起作用,因為它們不允許window.location,但可以在您的網站中使用。
HTML:
<a class="no-href" data-location="https://www.google.pt">Google</a><br />
<a class="no-href" data-location="https://www.google.com">Link 2</a><br />
<a class="no-href" data-location="https://www.google.co.za">Link 3</a><br />
<a href="https://www.google.pt/">Normal Link</a><br />
<br>
When I over the mouse on the link, it shows the URL on the bottom left corner.
<br>
<img src="http://i.imgur.com/pq3ket7.png">
<br>
Is there any way to prevent it?
I'm using Chrome.
JS:
$('.no-href').click(function(e){
e.preventDefault();
window.location = $(this).attr('data-location');
});
CSS:
.no-href {
color: blue;
cursor: pointer;
text-decoration: underline;
}
只需像這樣將其添加到OnClick:
<a href="javascript:;" onclick="location.href='https://www.google.pt/'">Google</a>
希望對您有幫助。
據此,它不能完成: https : //productforums.google.com/forum/?hl= zh-CN#!category- topic/ chrome/discuss-chrome/ FtD7qjochgw
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.