Forum Moderators: open

Message Too Old, No Replies

Simple href question

making a "relative" link

         

adventurewagen

7:16 pm on Aug 19, 2005 (gmt 0)

10+ Year Member



I have the following list of links (which link to layered divisions in the same page):

<a href='/homepage.aspx'>Homepage</a>
<a href='/homepage.aspx?sub=sub1'>Sub Section 1</a>
<a href='/homepage.aspx?sub=sub2'>Sub Section 2</a>

Is it possible to turn "homepage.aspx" into some sort of relative value that href understands? My goal is to make this set of links generic so that I can place them in a SSI file instead of having to hardcode each page name into each link when all I want to really reference are the same div's in each page.

So something like:
<a href='/X'>Homepage</a>
<a href='/X?sub=sub1'>Sub Section 1</a>
<a href='/X?sub=sub2'>Sub Section 2</a>

where 'X' represents "homepage.aspx" in this instance.

jdMorgan

7:49 pm on Aug 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If each of these links always points to the same page, regardless of the directory-path of the page containing the link, then what you want is a canonical URL:

Page-relative: <a href="page.html">
Server-relative: <a href="/page.html">
Canonical: <a href="http://www.example.com/page.html">

Jim

jdMorgan

7:53 pm on Aug 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On the other hand, after re-reading your post, if all you want is a URL relative to the current location, then you can just use the page-relative form shown above.

Hrefs are not resolved by SSI or your server, they are resolved by the client (browser). So the fact that the links are included as HTML text by SSI has no effect on the links.

Jim

adventurewagen

9:45 pm on Aug 19, 2005 (gmt 0)

10+ Year Member



Maybe one of those would work, let me try to explain what I've got better.

I have a bunch of different pages (page001.html to page100.html). Each page contains the same divisions (div1, div2, div3), the links in each page then reference each division to I can jump to those sections.

page001.html contains:

<a href='/page001.html?sub=div1'>Div 1 content</a>
<a href='/page001.html?sub=div2'>Div 2 content</a>
<a href='/page001.html?sub=div3'>Div 3 content</a>

page002.html contains:

<a href='/page002.html?sub=div1'>Div 1 content</a>
<a href='/page002.html?sub=div2'>Div 2 content</a>
<a href='/page002.html?sub=div3'>Div 3 content</a>

page003.html contains:

<a href='/page003.html?sub=div1'>Div 1 content</a>
<a href='/page003.html?sub=div2'>Div 2 content</a>
<a href='/page003.html?sub=div3'>Div 3 content</a>

and so on. What I want to do is replace the "page00n.html" with a non-specific path so I can create my 100 pages without having to rename 3 links per page.

Is there no way to essentially say "href='(the current page Im at).html'

Maybe Im going about this the wrong way? Could I use something like href="pointer" and give a div the name="pointer" attribute somehow?

adventurewagen

6:01 pm on Aug 23, 2005 (gmt 0)

10+ Year Member



Anybody? I've kept looking for a generic reference method to look at my "current page" but nothing seems to work?

I guess I might have to write up something to make it happen.

Trace

7:23 pm on Aug 23, 2005 (gmt 0)

10+ Year Member



I've done this before but only in ASP.

href="<%=request("URL")%>?id=120"

will output this

/forum21/10861-1-10.htm?id=120