开发者

HTML Urls - how to append to the existing url

This is a stupidly easy question, however after searching for a long ti开发者_运维知识库me I have yet to yield any results.

My question is as follows.

I have a webpage with the url http://domain.com/mypage/ladeda/

I have a link on this page.

<a href="/1/">Page 1</a>

That link sends me to http://domain.com/1/

<a href="1/">Page 1</a>

That link takes me to http://domain.com/mypage/1/

How do i get my link to take me to http://domain.com/mypage/ladeda/1/

without having to extract all the aspects of the page url and put them within the href.

Many Thanks


<base href="/mypage/ladeda/" />
...
<a href="1/">(goes to http://domain.com/mypage/ladeda/1/)</a>

Via the <base> element.


But!
<a href="1/">Page 1</a> should take you to http://domain.com/mypage/ladeda/1/ already provided that (a) you don't use a <base> element already and (b) the current resource is really http://domain.com/mypage/ladeda/ (with a trailing slash).


<a href="/mypage/ladeda/1">Page 1</a>

If the current page isn't in the same directory (real or virtual) as the target page, you're going to have to specify a complete path. Either relative, or absolute. There's no way around it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜