Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple link question

Status
Not open for further replies.

Scorez2000

Programmer
Feb 5, 2004
87
GB
Ok, lets say I have an HTML file in a folder called myfolder on a site called

What I want to do, is link to the root of the folder that the document is in. So that when clicked on, I go to:


The thing is, it needs to be a relative link so that it will work in any folder. I tried href="/" but that brings me back a folder to
Anyone any ideas?

Thanks in advance.

Wayne.
 
IF what you want is to have document.htm as the default document that you find when you browse any folder, you'll need to change your Webserver config to achieve this, if you let us know which one you are using we'll provide the info. You may also want to check that your ISP / web host allows this as well.
 
No, that's not what I want to do. I know how to do that.

Basically, at the bottom of every page I want a link that brings you back to the root of that folder (which is actually index.htm).

I have tried:

<a href="/">
Which brings me back a level, not to the root.

<a href="/myfolder/">
But that won't work if I move the files to another folder.
 
If index.htm is the default document in each of the folders then <a href="index.htm">
 
But what if it's not?

I have found something that works though.

<a href="">link</a> will bring you back to the root.
 
I'd try [tt]<a href=".">[/tt] or [tt]<a href="./">[/tt]. Leaving the href attribute blank looks suspect to me, and might not do the same thing in all browsers. Indeed, I'd expect it to link to the current document, not the current directory.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Checking w3c, a URI is specified for the href attribute of the a tag... And according to 4.0's DTD, a URI is just CDATA, so empty is "legal." It didn't, however, say what is to happen when a blank URI is given, so browsers may not all opperate the same way.

<a href="./">lalal</a> is preferable.

[plug=shameless]
[/plug]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top