469,623 Members | 1,800 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Open link with a Windows relative part %windir%

HI,
I try to open a link using %windir% in path:

<LI><A HREF="%windir%/temp/MainSetupLog.log">F </A></LI>

The browser does not seem to find the file.
However,If I paste in the Address window:

file:///%windir%/temp/MainSetupLog.log

It does open it properly.

Where is my problem ?

Thanks

Dec 25 '06 #1
8 5792
Scripsit MoshiachNow:
I try to open a link using %windir% in path:
Why? That doesn't make sense in the World Wide Web. What are you trying to
achieve by doing so, as opposite to using
<LI><A HREF="%windir%/temp/MainSetupLog.log">F </A></LI>
Makes no sense even syntactically. The "%" sign is reserved in URLs and
should thus be escaped. Besides, that would be a relative URL, relative to
the current base URL, not an absolute path in some file system.
However,If I paste in the Address window:

file:///%windir%/temp/MainSetupLog.log

It does open it properly.
That's an illusion. A file: URL may work within a particular computer, but
by definition, it is system-dependent. On a web page, it would refer to
something on the _user's_ computer, something that might very accidentally
exist. Advanced browsers may however prevent access to it from a web page
that way, as a security measure.
Where is my problem ?
I don't know, but I'm sure you're trying to solve the wrong problem now.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Dec 25 '06 #2
MoshiachNow wrote:
HI,
I try to open a link using %windir% in path:

<LI><A HREF="%windir%/temp/MainSetupLog.log">F </A></LI>

The browser does not seem to find the file.
However,If I paste in the Address window:

file:///%windir%/temp/MainSetupLog.log

It does open it properly.

Where is my problem ?

Thanks
First of all, what you want to do -- access a local file -- would work
only for you when the Web page itself is a local HTML file. Browsers
should not access local files from Web pages delivered from a Web
server. A browser that violates this rule has a serious security
vulnerability and should not be used.

The notation %windir% is symbolic for some actual local Windows
directory. You can't code it as a URL, even for a local HTML file.
Instead, you need the actual directory name. For example, your %windir%
for SeaMonkey (the browser that I use) might be [C:\Program
Files\SeaMonkey] while mine is [C:\SeaMonkey] because I don't install in
[Program Files].

Finally, the URL in the form <file:///[some local path]/[some local
file] is not the same as the URL in the form <[some local path]/[some
local file]>. The former is indeed for a local file in a local
directory. The latter is some file in a directory relative to the Web
page containing the reference.

--

David E. Ross
<http://www.rossde.com/>

Concerned about someone (e.g., Pres. Bush) snooping
into your E-mail? Use PGP.
See my <http://www.rossde.com/PGP/>
Dec 25 '06 #3
David E. Ross wrote:
MoshiachNow wrote:
>HI,
I try to open a link using %windir% in path:

<LI><A HREF="%windir%/temp/MainSetupLog.log">F </A></LI>

The browser does not seem to find the file.
However,If I paste in the Address window:

file:///%windir%/temp/MainSetupLog.log

It does open it properly.

Where is my problem ?

Thanks

First of all, what you want to do -- access a local file -- would work
only for you when the Web page itself is a local HTML file. Browsers
should not access local files from Web pages delivered from a Web
server. A browser that violates this rule has a serious security
vulnerability and should not be used.

The notation %windir% is symbolic for some actual local Windows
directory. You can't code it as a URL, even for a local HTML file.
No, actually, he's right when he says it works when typed into the
address line in IE, as surprising as that is.
Instead, you need the actual directory name. For example, your %windir%
for SeaMonkey (the browser that I use) might be [C:\Program
Files\SeaMonkey] while mine is [C:\SeaMonkey] because I don't install in
[Program Files].

Finally, the URL in the form <file:///[some local path]/[some local
file] is not the same as the URL in the form <[some local path]/[some
local file]>. The former is indeed for a local file in a local
directory. The latter is some file in a directory relative to the Web
page containing the reference.
Correct, though if he does put the form that works in the Address field,
with the "file:///" protocol, as the HREF, it still doesn't work.
Dec 25 '06 #4
VK
MoshiachNow wrote:
HI,
I try to open a link using %windir% in path:

<LI><A HREF="%windir%/temp/MainSetupLog.log">F </A></LI>

The browser does not seem to find the file.
However,If I paste in the Address window:

file:///%windir%/temp/MainSetupLog.log

It does open it properly.

Where is my problem ?
Browser is not a local file manager, it doesn't work with path but with
URL. The URLs format is defined in the RFC 1738, see if curious a copy
at <http://www.faqs.org/rfcs/rfc1738.html>

"%windir%/temp/MainSetupLog.log" string doesn't fit neither to relative
nor absolute URL syntax so is broken (in the browser context).

"file:///%windir%/temp/MainSetupLog.log" defines protocol FILE so it
can be potentially interpreted as a valid URL, so the browser gives it
a try.

FILE protocol as defined at section 3.10 of RFC 1738 has the form:
file://<host>/<path>

where <hostcan be empty string - this is interpreted then as "the
machine from which the URL is being interpreted".

<pathis a hierarchical directory path of the form
<directory>/<directory>/.../<name>

Because you have three slashes file:/// it is interpreted as <host>
being empty string with the above indicated meaning and <pathpart
being forwarded to the local file system for further processing. There
%windir% being resolved into c:/windows or wherever your Windows
installation is and c:/windows/temp/MainSetupLog.log file successully
loaded - if exists.

Dec 25 '06 #5
Dan

MoshiachNow wrote:
I try to open a link using %windir% in path:
....
Where is my problem ?
Trying to use system-specific stuff in a World Wide Web context? What
value of "%windir%" would you expect to exist on a MacOS or Linux
system?

--
Dan

Dec 26 '06 #6
Dan wrote:
MoshiachNow wrote:
>I try to open a link using %windir% in path:
...
>Where is my problem ?

Trying to use system-specific stuff in a World Wide Web context?
He isn't--he said in the previous thread that he's just creating pages
to run on his own local machine without a server. And I told him that
for that reason his posts are off-topic here, and suggested other
newsgroups that would relate to his questions, so why he's still barking
up this tree I can't say.
What
value of "%windir%" would you expect to exist on a MacOS or Linux
system?
Dec 26 '06 #7

MoshiachNow wrote:
HI,
I try to open a link using %windir% in path:

<LI><A HREF="%windir%/temp/MainSetupLog.log">F </A></LI>

The browser does not seem to find the file.
However,If I paste in the Address window:

file:///%windir%/temp/MainSetupLog.log

It does open it properly.
You didn't specify a protocol, like http:// or file:// in your <aThe
default is http:// and that doesn't understand the expansion of
environment variables like %windir%, so of course it doesn't work.

Even using file:///%windir%/temp/MainSetupLog.log is flakey. It might
work with one browser on one machine today, but don't expect it to work
reliably elsewhere.

Dec 27 '06 #8
Dan

Andy Dingley wrote:
You didn't specify a protocol, like http:// or file:// in your <aThe
default is http:// and that doesn't understand the expansion of
environment variables like %windir%, so of course it doesn't work.
There isn't a "default" protocol in URIs. Protocol-less links are
considered to be relative rather than absolute URIs, and are handled
with the protocol in the base URI of the document containing the link.

--
Dan

Dec 28 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by venkatesh | last post: by
40 posts views Thread by Brian Jorgenson | last post: by
10 posts views Thread by David McCulloch | last post: by
23 posts views Thread by Markus | last post: by
2 posts views Thread by Martin Geisler | last post: by
4 posts views Thread by Abhishek Srivastava | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.