On medium.com they have a clickable link on an h3 element, however the browser seems to know the URL that it will take you to and shows it in the bottom left side of the screen.
When I inspect element I see that this link is only an h3 element. It has a name attribute, an id and a class on it. There is no element and there is no href.
I assume that they listen to the click event of this element and then redirect the user to the correct page, but what I don't understand is how google chrome knows that this is a link and even shows the url it will take you to.
Is this something the browser now supports? Is there a specific way of forcing the browser to show it?
以外的元素上的Javascript链接答案 0 :(得分:1)
答案 1 :(得分:-1)
是的,它可以通过一个简单的监听器完成,例如在jQuery中:
<h3 id="link1">Link1</h3>
代码隐藏:
$("#link1").click(function () {
window.location.href = "http://www.google.com";
});
应该可以在任何现代浏览器中使用,但我说他们都会以不同的方式解释它。我不确定我们是否真的需要知道它为什么会起作用,只是确实如此 - 你可以在浏览器中询问任何是如何工作的。据推测,他们会在加载代码时快速解析所有代码,以便他们知道所有可能发生的事件。像this这样的东西可能会有所帮助。
答案 2 :(得分:-1)
但如果不是Siguza finde <a href>
。我认为chrom count dependecis并显示重定向页面或功能。状态栏,您可以关闭或打开。或者改变错误&#34;重定向就像你能表现出来的那样#34;我是最好的&#34;采取
<a href="Im the Best!">test</a>
显示:localhost34567/Im the Best!
---&gt;好吧不完美:D但你可以玩它并有更好的结果。
https://superuser.com/questions/239202/turn-off-the-link-hover-statusbar-in-google-chrome