Basic query

Discussion in 'HTML' started by KiwiBrian, Oct 30, 2004.

  1. KiwiBrian

    KiwiBrian Guest

    I want to have a few special files in my root directory and be able to link
    to them from anywhere in the lower levels of the site hierarchy.
    I am familiar with the ../ method of going up a level in the path but this
    implies that I know how deep the calling file is nested.
    Is there a method of addressing that will allow me to locate the calling
    file anywhere in the hierarchy, and will work regardless of whether the site
    is on my hard drive or on a server?
    I hope I am being clear.
    I hope there is a simple answer.
    TIA
    Brian Tozer
    KiwiBrian, Oct 30, 2004
    #1
    1. Advertising

  2. KiwiBrian

    brucie Guest

    In alt.html KiwiBrian said:

    > Is there a method of addressing that will allow me to locate the calling
    > file anywhere in the hierarchy, and will work regardless of whether the site
    > is on my hard drive or on a server?


    href="/directory/myfile.ext"

    '/' starts from the root

    --

    v o i c e s o f t h e l i t t l e
    brucie, Oct 30, 2004
    #2
    1. Advertising

  3. KiwiBrian

    Dave Patton Guest

    "KiwiBrian" <> wrote in
    news:cluioc$v3b$:

    > I want to have a few special files in my root directory and be able to
    > link to them from anywhere in the lower levels of the site hierarchy.


    The path "/" is the root, so you would have:
    href="/specialK.gif" etc.

    > Is there a method of addressing that will allow me to locate the
    > calling file anywhere in the hierarchy, and will work regardless of
    > whether the site is on my hard drive or on a server?


    That's not clear - what exactly do you want?
    What do you mean by "locate the calling file"?

    --
    Dave Patton
    Canadian Coordinator, Degree Confluence Project
    http://www.confluence.org/
    My website: http://members.shaw.ca/davepatton/
    Dave Patton, Oct 30, 2004
    #3
  4. KiwiBrian

    KiwiBrian Guest

    "brucie" wrote ...
    > In alt.html KiwiBrian said:


    >> Is there a method of addressing that will allow me to locate the calling
    >> file anywhere in the hierarchy, and will work regardless of whether the
    >> site
    >> is on my hard drive or on a server?


    > href="/directory/myfile.ext"
    >
    > '/' starts from the root


    Thanks for your reply Brucie.
    Maybe I worded my enquiry poorly, or maybe I am misunderstanding your reply.
    I wish to utilise a background graphic file 'pgbk.jpg' that is in a
    subfolder 'hpfiles' of my root directory.
    I wish to call/access this from my .CSS files that are in various levels of
    the site hierarchy so that all pages are using the same graphic.
    I tried to implement what I thought you were telling me as follows:-

    background-image: url(/hpfiles/pgbk.jpg);

    This did not work as the root directory is several levels higher in the
    hierarchy.
    I would expect it to only work if the 'hpfiles' directory was a subdirectory
    of the calling directory.
    I hope you can clarify this for me.

    Brian Tozer
    KiwiBrian, Oct 30, 2004
    #4
  5. KiwiBrian

    rf Guest

    KiwiBrian wrote:
    > "brucie" wrote ...
    > > In alt.html KiwiBrian said:

    >
    > >> Is there a method of addressing that will allow me to locate the

    calling
    > >> file anywhere in the hierarchy, and will work regardless of whether the
    > >> site
    > >> is on my hard drive or on a server?

    >
    > > href="/directory/myfile.ext"
    > >
    > > '/' starts from the root


    > background-image: url(/hpfiles/pgbk.jpg);


    > This did not work as the root directory is several levels higher in the
    > hierarchy.
    > I would expect it to only work if the 'hpfiles' directory was a

    subdirectory
    > of the calling directory.


    / refers to the root.

    Even if your CSS file is
    example.com/folder/folder/folder/example.css
    /hpfiles/pgbk.jpg refers to the file
    example.com/hpfiles/pgbk.jpg

    What about putting the name in " like the spec suggests?

    background-image: url("/hpfiles/pgbk.jpg");

    --
    Cheers
    Richard.
    rf, Oct 30, 2004
    #5
  6. KiwiBrian

    KiwiBrian Guest

    "rf" <rf@.invalid> wrote in message
    news:UzFgd.3497$...
    > KiwiBrian wrote:
    >> "brucie" wrote ...
    >> > In alt.html KiwiBrian said:

    >>
    >> >> Is there a method of addressing that will allow me to locate the

    > calling
    >> >> file anywhere in the hierarchy, and will work regardless of whether
    >> >> the
    >> >> site
    >> >> is on my hard drive or on a server?

    >>
    >> > href="/directory/myfile.ext"
    >> >
    >> > '/' starts from the root

    >
    >> background-image: url(/hpfiles/pgbk.jpg);

    >
    >> This did not work as the root directory is several levels higher in the
    >> hierarchy.
    >> I would expect it to only work if the 'hpfiles' directory was a

    > subdirectory
    >> of the calling directory.

    >
    > / refers to the root.
    >
    > Even if your CSS file is
    > example.com/folder/folder/folder/example.css
    > /hpfiles/pgbk.jpg refers to the file
    > example.com/hpfiles/pgbk.jpg
    >
    > What about putting the name in " like the spec suggests?
    >
    > background-image: url("/hpfiles/pgbk.jpg");


    Just tried that thanks Richard but still didn't work.
    I am testing this on my HD.
    How does the browser know where my root folder is?
    I test by opening the index.html file in the 'root directory' and use the
    site menu from there.
    When I get to the test page, voila, no background.
    Am I missing something very basic?

    Brian Tozer
    KiwiBrian, Oct 30, 2004
    #6
  7. KiwiBrian

    Neal Guest

    On Sat, 30 Oct 2004 18:43:34 +1300, KiwiBrian <> wrote:

    > Just tried that thanks Richard but still didn't work.
    > I am testing this on my HD.
    > How does the browser know where my root folder is?
    > I test by opening the index.html file in the 'root directory' and use the
    > site menu from there.
    > When I get to the test page, voila, no background.
    > Am I missing something very basic?


    Perhaps.

    On my OS (W98) the directories are delineated with \. On the web, they are
    marked with /.

    So, if I try to view a page which references a \ location, it fails.

    I suspect that's your trouble.
    Neal, Oct 30, 2004
    #7
  8. KiwiBrian

    Neal Guest

    On Sat, 30 Oct 2004 01:50:11 -0400, Neal <> wrote:

    > On my OS (W98) the directories are delineated with \. On the web, they
    > are marked with /.
    >
    > So, if I try to view a page which references a \ location, it fails.
    >
    > I suspect that's your trouble.


    Worded that poorly.

    On my computer, I must go to "directory\file.ext"

    On the server, it's "directory/file.ext"

    Hope that clears it up.
    Neal, Oct 30, 2004
    #8
  9. KiwiBrian

    KiwiBrian Guest

    "Neal" <> wrote in message
    news:eek:...
    > On Sat, 30 Oct 2004 18:43:34 +1300, KiwiBrian <> wrote:
    >
    >> Just tried that thanks Richard but still didn't work.
    >> I am testing this on my HD.
    >> How does the browser know where my root folder is?
    >> I test by opening the index.html file in the 'root directory' and use the
    >> site menu from there.
    >> When I get to the test page, voila, no background.
    >> Am I missing something very basic?

    >
    > Perhaps.
    >
    > On my OS (W98) the directories are delineated with \. On the web, they are
    > marked with /.
    >
    > So, if I try to view a page which references a \ location, it fails.
    >
    > I suspect that's your trouble.


    Thanks Neal, but all accessing is being done with the browser. I am using /
    extensively within the site and it is only this situation which does not
    work.
    I have just tried both single and double-quotes around the path and filename
    (just within the brackets), but no joy.

    Brian Tozer
    KiwiBrian, Oct 30, 2004
    #9
  10. KiwiBrian

    brucie Guest

    In alt.html KiwiBrian said:

    > I have just tried both single and double-quotes around the path and filename
    > (just within the brackets), but no joy.


    how long are you going to keep stringing everyone along before you post
    a URL demonstrating the problem?

    after of course running it through validation

    http://validator.w3.org/
    http://jigsaw.w3.org/css-validator/


    --

    v o i c e s o f t h e l i t t l e
    brucie, Oct 30, 2004
    #10
  11. KiwiBrian

    KiwiBrian Guest

    "brucie" <> wrote in message
    news:...
    > In alt.html KiwiBrian said:
    >
    >> I have just tried both single and double-quotes around the path and
    >> filename
    >> (just within the brackets), but no joy.

    >
    > how long are you going to keep stringing everyone along before you post
    > a URL demonstrating the problem?
    >
    > after of course running it through validation
    >
    > http://validator.w3.org/
    > http://jigsaw.w3.org/css-validator/


    Fair comment Brucie, but unfortunately that is not possible with this site
    at the moment.
    However I do appreciate the help and it has given me some avenues to pursue.
    If necessary I will mock up a simulation of the problem to put online.
    I had initilly assumed that the problem was just my lack of knowledge of the
    proper method, but you have clarified that.
    Thanks again.
    The operation was a success, but unfortunately the patient died.

    Brian Tozer
    KiwiBrian, Oct 30, 2004
    #11
  12. KiwiBrian

    brucie Guest

    In alt.html KiwiBrian said:

    > If necessary I will mock up a simulation of the problem to put online.


    thats a good idea

    > The operation was a success, but unfortunately the patient died.


    it should work without an issue so you're doing something wrong
    somewhere.

    --

    v o i c e s o f t h e l i t t l e
    brucie, Oct 30, 2004
    #12
  13. KiwiBrian wrote:

    > I want to have a few special files in my root directory and be able to
    > link to them from anywhere in the lower levels of the site hierarchy.
    > I am familiar with the ../ method of going up a level in the path but this
    > implies that I know how deep the calling file is nested.


    As mentioned by others, construct the URI relative to the root of the host
    with a '/' at the front of the URI.

    > Is there a method of addressing that will allow me to locate the calling
    > file anywhere in the hierarchy, and will work regardless of whether the
    > site is on my hard drive or on a server?


    Using '/' will either work to the root of your filesystem (on UNIX-like
    systems) or (I guess) the root of the current drive (on MSDOS-like
    systems). Run your own webserver (The industry standard, Apache, is free
    for many operating systems <http://httpd.apache.org/>), then access your
    local site through that. This will let you have it based around a sensible
    site root (and let you test your implementation of any server side
    technologies you might wish to use).

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Oct 30, 2004
    #13
  14. KiwiBrian

    rf Guest

    KiwiBrian wrote:
    " <> wrote in message
    news:clv9m6$kpo$...

    > > Even if your CSS file is
    > > example.com/folder/folder/folder/example.css
    > > /hpfiles/pgbk.jpg refers to the file
    > > example.com/hpfiles/pgbk.jpg
    > >
    > > What about putting the name in " like the spec suggests?
    > >
    > > background-image: url("/hpfiles/pgbk.jpg");

    >
    > Just tried that thanks Richard but still didn't work.
    > I am testing this on my HD.


    Bloody hell.

    Why... did... you... not... state... this... before...?


    The "root" folder on your hard disk is, of course, c:\.

    Is there a c:\hpfiles\ folder on your hard disk? I'll bet not. It would be
    called something like
    c:\\web documents\www\root\hpfiles\ wouldn't it.

    Of course the browser can't find the file. You have put it elsewhere than
    where you told the browser it is.

    > How does the browser know where my root folder is?


    It doesn't. It doesn't care. It tells whatever file system it is accessing
    "give me this file", which happens to be /hpdocs/pgbk.gif. For file:// (the
    local file system) this resolves to c:\hpdocs\pgbk.gif. For http:// (the
    web) it resolves to http://example.com/hpdocs/pgbk.gif which happens to be a
    file in a folder that is in the web root.

    > I test by opening the index.html file in the 'root directory' and use the
    > site menu from there.
    > When I get to the test page, voila, no background.


    > Am I missing something very basic?


    Yep. web != local file system.

    You have four alternatives:

    1) put your entire site in the root folder of your hard disk, that is c:\.
    Not a good thing to do.

    2) Upload the site to a web host somewhere and test from there. Not really
    required.

    3) Download and install a web server. Apache comes for free and takes about
    5 minutes to install. Good thing to do.

    4) Trick the file system into thinking that c:\\web documents\www\root\ *is*
    a root. Sneaky but quick and it works.

    Do this:
    Share the above folder on the network.
    Go to My Network Places, navigate to this shared folder and "map network
    drive" it to, say, drive z:.

    Then c:\web documents\www\root\ can be also referenced as z:\ and z:\is the
    root of this "drive" and z:\hpfiles\ is a valid folder and from the browsers
    point of view (if you are viewing z:\somefolder\somefile.html) and
    url("/hpfiles/pgbk.jpg") resolves (via the file system) to
    z:\hpfiles\pgbk.jpg and this exists, even though its real address is c:\web
    documents\www\root\hpfiles\pgbk.gif.

    OK?

    --
    Cheers
    Richard.
    rf, Oct 30, 2004
    #14
  15. KiwiBrian

    brucie Guest

    In alt.html rf said:

    > 3) Download and install a web server. Apache comes for free and takes about
    > 5 minutes to install. Good thing to do.


    <bangs head on desk/>
    it never occurred to me that he wasn't already using one

    > OK?


    no, i've been doing too much head banging of late. everything inside has
    gone all wobbly.


    --

    v o i c e s o f t h e l i t t l e
    brucie, Oct 30, 2004
    #15
  16. KiwiBrian

    rf Guest

    brucie wrote

    > <bangs head on desk/>


    stop doing that. it shakes up the hamsters.

    --
    Cheers
    Richard.
    rf, Oct 30, 2004
    #16
  17. KiwiBrian

    KiwiBrian Guest

    "David Dorward" and others wrote

    Many thanks to everyone who contributed to this thread.
    Much appreciated.
    Normal programming is now resumed.

    Brian Tozer
    KiwiBrian, Oct 30, 2004
    #17
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    6
    Views:
    3,365
    Steven Cheng[MSFT]
    Jun 29, 2005
  2. KiwiBrian

    Basic CSS query

    KiwiBrian, Jul 11, 2003, in forum: HTML
    Replies:
    4
    Views:
    495
    Leif K-Brooks
    Jul 12, 2003
  3. Brian Tozer

    Basic query

    Brian Tozer, Oct 4, 2003, in forum: HTML
    Replies:
    2
    Views:
    417
    Brian Tozer
    Oct 5, 2003
  4. Engineer
    Replies:
    6
    Views:
    612
    Jeremy Bowers
    May 1, 2005
  5. Replies:
    0
    Views:
    428
Loading...

Share This Page