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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

http or file in relative path link

Status
Not open for further replies.

fawkes

Technical User
Sep 12, 2003
343
GB
I'm trying to establish a link to an ASP page using a relative path, the problem is that the browser(ie6) always sets the link to file:///myfile.asp, this causes the file to open in my developemnt environment. When I hard code the link the file opens in the browser.

The question is how do I write a link
Code:
<a href="myfile.asp">myfile</a>
so that it opens in the browser and not the development environment.
 
When you put relative links in browser will assume everything else is the same, except from the point your relative link began. Since you begin with a file name, this means that everything up to the filename remains unchanged: the folder, the server and the protocol. If the page where you call the link was opened via file:/// protocol, your relative link will assume the same. If it was opened via http:// protocol, it will be used for your linked file as well. Hope it makes sense.
 
Is there any way of controlling this?

I'm constructing an intranet so users could open it with shortcuts that specificaly state equally they could have shortcuts that specifically state //myfolder/index.htm.

If the second option is chosen then the relative path would start file:// not
Can I tell the web page to open a link in the browser and not the development environement?
 
fawkes said:
Is there any way of controlling this?
Yes, provide an absolute link including the protocol. That way you tell the link to open with a specific protocol.
 
Is there any way of controlling this without an absolute link? I'm constructing the site locally to place on a server later.
 
It's a risky process and good design should remove risk.
 
Figured it out

Code:
<head>
    ...

    <base href="[URL unfurl="true"]http://myfolder/"/>[/URL]
</head>

This forces the base for the relative paths.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top