html中的相对链接 [英] relative links in html

查看:184
本文介绍了html中的相对链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. < p> a href =http://www.example.com/page.html>链接页面< / a>

  2. < a href =// page2.html>链接页面< / a>

  3. < a href = /page3.html\">链接页面< / a>

  4. < a href =./ page4.html> ; link page< / a>

  5. < a href =../ page5.html>链接页面< a>

所以在上面的列表中,


  1. 是绝对链接

  2. 相对于网站根,http或https

  3. 与网站相关根目录?

  4. 位于当前目录中?

  5. 位于目录中?


解决方案

这不是HTML。这是操作系统所有方面的绝对或相对路径。


  1. 是的,没有解释。是没有SSL(https)的链接

  2. 是。如果用户通过http访问网站,则会自动切换到http;如果用户通过https访问网站,则会自动切换到http。

  3. 是。它链接到 // domain / thelink.ext

  4. 是的。和操作系统一样, ./ 是当前目录。很多时候你必须指定这个以确保是最新的。

  5. 是的。在操作系统中, ../ 更改为父目录。您可以进行嵌套,并且 ../../../ 将表示最多3个父目录。


I have been looking for a complete definitive explanation of absolute vs relative links in HTML.

  1. <a href="http://www.example.com/page.html">link page</a>
  2. <a href="//page2.html">link page</a>
  3. <a href="/page3.html">link page</a>
  4. <a href="./page4.html">link page</a>
  5. <a href="../page5.html">link page</a>

So in the above list,

  1. is an absolute link
  2. is relative to site root with either http or https
  3. is relative to site root?
  4. is in the current directory?
  5. is up a directory?

解决方案

This is not HTML. This is absolute or relative paths in all aspects of a operating system.

  1. Yes, there's no interpretation. Is a link without SSL (https)
  2. Yes. It switches automatically to http if user visit the web in http, and https if user visit the web in https.
  3. Yes. It links to the //domain/thelink.ext
  4. Yes. As in a operating system, ./ is the current directory. Many times you must to specify this to ensure is the current.
  5. Yes. As in a operating system, ../ changes to parent directory. You can make nesting and ../../../ will mean that up 3 parent directories.

这篇关于html中的相对链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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