关于链接的一般问题

发布于 2024-10-13 01:02:29 字数 334 浏览 4 评论 0原文

我觉得问这个问题有点愚蠢,但是...:)

如果我是某个网站的访问者(比如说“www.site.com”),并且我目前在这个页面“www.site.com”上/pageX”,然后我打开该页面的源代码,我会找到一些“”标签。如果这些标签具有类似 href="/pageY/.content.html" 的 href,我如何判断(无需单击该链接,或查看链接完整地址)链接是否指向“www.site.com/pageY/content.html”。 html”或“www.site.com/pageX/PageY/content.html”?

我希望这个问题不会太令人困惑:)

I feel i little bit stupid to ask this, but... :)

If i'm visitor of some website (let's say "www.site.com"), and i'm currently on this page "www.site.com/pageX" and I open that page's source, i'll find some "<A>" tags. If those tags have hrefs like this href="/pageY/.content.html" how can I tell (without clicking that link, or looking at links full address) if link points to "www.site.com/pageY/content.html" OR "www.site.com/pageX/PageY/content.html"?

I hope this question is not too confusing :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夜唯美灬不弃 2024-10-20 01:02:29

当 URL 以斜杠 / 开头时,它会从站点的根目录开始。因此 href="/pageY/content.html" 将指向 www.site.com/pageY/content.html。而 href="pageY/content.html" 则指向当前位置:www.site.com/pageX/pageY/content.html。

When the URL starts with a slash / then it starts from the root of the site. So href="/pageY/content.html" will point to www.site.com/pageY/content.html. While href="pageY/content.html" points to the current location so: www.site.com/pageX/pageY/content.html.

小瓶盖 2024-10-20 01:02:29

如果您看到链接文本,则该链接链接到具有相同 URL 的当前页面。您还经常在表单中看到将 POST 数据发布到同一 URL。 :)

If you see <a href="">Text of link</a> then that link links to the current page with the same URL. You also see that often in forms to post the POST-data to the same URL. :)

忱杏 2024-10-20 01:02:29

您可以看出,因为该链接以 / 开头,这意味着它将相对于站点根目录。

您可以在这里阅读更多相关信息:http://www.motive.co.nz /glossary/linking.php#root

You can tell because that link starts with a / which means it will be relative to the site root.

You can read more about this here: http://www.motive.co.nz/glossary/linking.php#root

空心↖ 2024-10-20 01:02:29

不确定我是否正确理解了这个问题,但会尝试解释。

URL 有相对 URL 和绝对 URL。相对 URL 类似于 content.html./content.html。绝对 URL 以 / 开头,例如 /pageX/content.html

相对 URL 将附加到基本 href,即您所在的目录(www.site.com/pageX 表示 www.site.com/pageX/index.html)。可以使用 元素更改基本 href。当您访问 www.site.com/pageX 时访问 content.html 会将您引导至 www.site.com/pageX/content.html.

绝对 URL 始终将 URL 附加到域中。当您访问 www.site.com/pageX 时访问 /content.html 会将您引导至 www.site.com/content.html

不知道这是否回答了你的问题。

Not sure I understand the question correctly, but will try to explain.

There are relative and absolute URL's. Relative URL's look like content.html or ./content.html. Absolute URL's start with an /, like /pageX/content.html.

Relative URL's will be appended to the base href, which is the directory you're in (www.site.com/pageX for www.site.com/pageX/index.html). The base href can be changed with the <base/> element. Visiting content.html when you're on www.site.com/pageX would lead you to www.site.com/pageX/content.html.

Absolute URL's will always append the URL to the domain. Visiting /content.html when you're on www.site.com/pageX would lead you to www.site.com/content.html.

Don't know if that answered your question though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文