什么时候链接有一个磅#“登录它 [英] What is it when a link has a pound "#" sign in it

查看:90
本文介绍了什么时候链接有一个磅#“登录它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查了一些网站,并且他们在网址中有一个磅(#)符号。它是干什么的?

 < a href =#>链接名称< / a> 


解决方案

这是一个片段或命名锚点。您可以使用链接到文档的部分。通常,当您链接到页面时,浏览器会在页面顶部打开它。但是,您可以使用片段链接到该标题(或其他)。



如果没有< a name =whatever/> 标签,然后浏览器将链接到页面的顶部。如果片段为空,那么它也将链接到页面顶部。



仅用于片段 < a href =#>链接名称< / a> ,那么这只是指向当前页面顶部的链接。 b
$ b

您经常会看到与javascript结合使用的那种链接。符合标准的HTML需要一个 href 属性,但是如果你打算用javascript来处理请求,那么#是一个合理的占位符。


I have inspected some sites and they have a pound(#) sign in the url. What does it do?

 <a href="#" >Link name</a>

解决方案

It's a "fragment" or "named anchor". You can you use to link to part of a document. Typically when you link to a page, the browser opens it up at the top of the page. But you link to a section half-way down, you can use the fragment to link to that heading (or whatever).

If there is no <a name="whatever"/> tag within the page, then the browser will just link to the top of the page. If the fragment is empty, then it will also just link to the top of the page.

For a fragment only <a href="#">Link name</a>, then that's just a link to the top of the current page.

You often see that kind of link used in conjuction with javascript. Standards compliant HTML requires a href attribute, but if you're planning to handle the request with javascript then "#" serves as a reasonable place holder.

这篇关于什么时候链接有一个磅#“登录它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆