开发者

general question about links

开发者 https://www.devze.com 2023-02-05 19:52 出处:网络
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 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 lookin开发者_开发技巧g 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 :)


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.


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. :)


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消