html中的相对链接 [英] relative links in html
本文介绍了html中的相对链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
-
< p> a href =http://www.example.com/page.html>链接页面< / a>
-
< a href =// page2.html>链接页面< / a>
-
< a href = /page3.html\">链接页面< / a>
-
< a href =./ page4.html> ; link page< / a>
-
< a href =../ page5.html>链接页面< a>
所以在上面的列表中,
- 是绝对链接
- 相对于网站根,http或https
- 与网站相关根目录?
- 位于当前目录中?
- 位于目录中?
解决方案
这不是HTML。这是操作系统所有方面的绝对或相对路径。
- 是的,没有解释。是没有SSL(https)的链接
- 是。如果用户通过http访问网站,则会自动切换到http;如果用户通过https访问网站,则会自动切换到http。
- 是。它链接到
// domain / thelink.ext
- 是的。和操作系统一样,
./
是当前目录。很多时候你必须指定这个以确保是最新的。 - 是的。在操作系统中,
../
更改为父目录。您可以进行嵌套,并且../../../
将表示最多3个父目录。
I have been looking for a complete definitive explanation of absolute vs relative links in HTML.
<a href="http://www.example.com/page.html">link page</a>
<a href="//page2.html">link page</a>
<a href="/page3.html">link page</a>
<a href="./page4.html">link page</a>
<a href="../page5.html">link page</a>
So in the above list,
- is an absolute link
- is relative to site root with either http or https
- is relative to site root?
- is in the current directory?
- is up a directory?
解决方案
This is not HTML. This is absolute or relative paths in all aspects of a operating system.
- Yes, there's no interpretation. Is a link without SSL (https)
- Yes. It switches automatically to http if user visit the web in http, and https if user visit the web in https.
- Yes. It links to the
//domain/thelink.ext
- Yes. As in a operating system,
./
is the current directory. Many times you must to specify this to ensure is the current. - Yes. As in a operating system,
../
changes to parent directory. You can make nesting and../../../
will mean that up 3 parent directories.
这篇关于html中的相对链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文