UPDATE
<font onclick="window.open('https://www.google.pt/', '_self');" style="background:0;border:0;outline:0">Link
I had to use a tag to add the event to the text so I used font
because it doesn't modify anything. PS: This doesn't work on JS Fiddle as, for some reason, it doesn't open the link (it stays blank).
<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.
It's uncontrolled browser behavior.
You can convert it to a div, attach a click event listener an open the wanted url in the callback function.
The JSFiddle broke so I will just paste all the code here. Please note that the links won't work in JSFiddle because they do not allow window.location but it will work in your website.
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;
}
Simply add it to OnClick like this:
<a href="javascript:;" onclick="location.href='https://www.google.pt/'">Google</a>
Hope it helps you.
据此,它不能完成: https : //productforums.google.com/forum/?hl= zh-CN#!category- topic/ chrome/discuss-chrome/ FtD7qjochgw
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.