![]() |
|
|
|||||||
![]() |
HTML - single dot prefix for hyperlinks |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hi,
Can anyone tell me the difference between the following where "Test.asp" is found in the same folder as the target page calling the hyperlink "Last Image"? 1. <a href="./Test.csp">Last Image</a> 2. <a href="Test.asp">Last Image</a> Thanks in advance, Dave Dave |
|
|
|
|
#2 |
|
Posts: n/a
|
Dave wrote: > Can anyone tell me the difference between the following where > "Test.asp" is found in the same folder as the target page calling the > hyperlink "Last Image"? > > 1. <a href="./Test.csp">Last Image</a> > 2. <a href="Test.asp">Last Image</a> One is "csp" Otherwise the resolution of the URLs ought to point to the same directory. As to the actuality for your real server, then take the URL of this page (which you didn't tell us) and see what you get by following each link. The LiveHTTPHeaders extension for Firefox is worth using for this. |
|
|
|
#3 |
|
Posts: n/a
|
"Dave" <> wrote in message
news: oups.com... > Hi, > > Can anyone tell me the difference between the following where > "Test.asp" is found in the same folder as the target page calling the > hyperlink "Last Image"? > > 1. <a href="./Test.csp">Last Image</a> > 2. <a href="Test.asp">Last Image</a> > > Thanks in advance, > Dave One is two characters longer than the other. Seriously, I think that is the only difference. A single dot "." is a reference to the current directory (similar to ".." referring to the parent), so "./Test.csp" is the same as "Test.csp". -- Brian Cryer www.cryer.co.uk/brian |
|
|
|
#4 |
|
Posts: n/a
|
"Brian Cryer" <> wrote in message
news:... > "Dave" <> wrote in message > news: oups.com... >> Hi, >> >> Can anyone tell me the difference between the following where >> "Test.asp" is found in the same folder as the target page calling the >> hyperlink "Last Image"? >> >> 1. <a href="./Test.csp">Last Image</a> >> 2. <a href="Test.asp">Last Image</a> >> >> Thanks in advance, >> Dave > > One is two characters longer than the other. > > Seriously, I think that is the only difference. A single dot "." is a > reference to the current directory (similar to ".." referring to the > parent), so "./Test.csp" is the same as "Test.csp". oops. Except, as pointed out by Andy, had I put my glasses on I would have noticed one was .csp and the other .asp. (silly me). Nevertheless, "./Test.csp" is the same as "Test.csp". |
|
|
|
#5 |
|
Posts: n/a
|
Dave wrote:
> Can anyone tell me the difference between the following where > "Test.asp" is found in the same folder as the target page calling the > hyperlink "Last Image"? > > 1. <a href="./Test.csp">Last Image</a> > 2. <a href="Test.asp">Last Image</a> Ignoring the typo (".csp" vs. ".asp"), there is no difference. A single dot (.), as the only character in a path segment[1], simply refers to the "same" path segment. It's just stripped out, though it can be useful[2] on rare occasions. With a base URI of: http://www.example.com/foo/ all of: bar/baz.html ./bar/baz.html bar/./baz.html ./bar/./baz.html resolve to: http://www.example.com/foo/bar/baz.html Section 5.4 Reference Resolution Examples of RFC 3986 shows several examples of dot-segment resolution. Mike [1] Along with "..", these are also known as dot-segments. [2] A relative-path reference cannot start with a path segment that contains a colon as this would look like a URI starting with a scheme: foo:bar/baz.html (scheme: "foo", path: "bar/baz.html") To make the relative nature of the reference explicit, it can be prefixed with a "." dot-segment: ./foo:bar/baz.html |
|
|
|
#6 |
|
Posts: n/a
|
"Dave" <> wrote in message news: oups.com... > Hi, > > Can anyone tell me the difference between the following where > "Test.asp" is found in the same folder as the target page calling the > hyperlink "Last Image"? > > 1. <a href="./Test.csp">Last Image</a> > 2. <a href="Test.asp">Last Image</a> > > Thanks in advance, > Dave > Either can be used, but 2 distinctively tells the coding to look in this folder. As I've always understood it, the / means another folder or directory. The dot says, "backup one level then use this directory or folder". A leftover shortcut from DOS. |
|
|
|
#7 |
|
Posts: n/a
|
richard wrote:
> > "Dave" <> wrote in message > news: oups.com... >> Hi, >> >> Can anyone tell me the difference between the following where >> "Test.asp" is found in the same folder as the target page calling the >> hyperlink "Last Image"? >> >> 1. <a href="./Test.csp">Last Image</a> >> 2. <a href="Test.asp">Last Image</a> >> >> Thanks in advance, >> Dave >> > > Either can be used, but 2 distinctively tells the coding to look in this > folder. > As I've always understood it, the / means another folder or directory. > The dot says, "backup one level then use this directory or folder". > A leftover shortcut from DOS. > Close but not quite: one dot './' means this folder in DOS 2 dots '../' means backup one level in DOS -- Take care, Jonathan ------------------- LITTLE WORKS STUDIO http://www.LittleWorksStudio.com |
|
|
|
#8 |
|
Posts: n/a
|
On Thu, 21 Sep 2006, richard wrote:
[otiose quotage snipped yet again. Isn't it time you started following good usenet netiquette?] > As I've always understood it, the / means another folder or > directory. No. URLs (which is what these are) define their own hierarchy, which, in principle, is completely independent of any server-specific file system, folders etc. The data might not be stored in ordinary files at all, but might be in a database, or be generated on-the-fly from some other source. In practice you will, of course, often find that the server is configured so that a certain sub-tree of the server's file hierarchy is mapped to a corresponding sub-tree of URLs, but this is by no means fundamental to the web. Quite the contrary, in fact (the URL hierarchy is not meant to expose internal details of web server file hierarchies etc.). As long as one misses this distinction, things may appear to be going just fine for quite a while, but sooner or later there will be a big surprise. > A leftover shortcut from DOS. I think the original designers of the URL scheme would quite resent your implications. |
|
|
|
#9 |
|
Posts: n/a
|
Andy Dingley wrote:
> Otherwise the resolution of the URLs ought to point to the same > directory. No, the resolution of the relative URLs produces the same _absolute URL_. Whether the server happens to treat it as referring to a directory is just coincidental (see Alan Flavell's reply). > As to the actuality for your real server, then take the URL > of this page (which you didn't tell us) and see what you get by > following each link. The server is not involved in any way in the URL resolution business, which is just string manipulation carried out by the _browser_. Only after resolving the absolute URL will the browser try to contact the server, and the server only gets the resolved absolute URL (split into parts, but that's irrelevant here). -- Jukka K. Korpela ("Yucca") http://www.cs.tut.fi/~jkorpela/ |
|
|
|
#10 |
|
Posts: n/a
|
"Jonathan N. Little" <> wrote in message
news:a36c5$4512f5b1$40cba7ac$... > richard wrote: >> >> "Dave" <> wrote in message >> news: oups.com... >>> Hi, >>> >>> Can anyone tell me the difference between the following where >>> "Test.asp" is found in the same folder as the target page calling the >>> hyperlink "Last Image"? >>> >>> 1. <a href="./Test.csp">Last Image</a> >>> 2. <a href="Test.asp">Last Image</a> >>> >>> Thanks in advance, >>> Dave >>> >> >> Either can be used, but 2 distinctively tells the coding to look in this >> folder. >> As I've always understood it, the / means another folder or directory. >> The dot says, "backup one level then use this directory or folder". >> A leftover shortcut from DOS. >> > Close but not quite: > > one dot './' means this folder in DOS > 2 dots '../' means backup one level in DOS or UNIX. -- Brian Cryer www.cryer.co.uk/brian |
|