Results 1 to 2 of 2

Thread: Simple question about files/directories

  1. #1
    Join Date
    May 2006
    Posts
    275

    Simple question about files/directories

    I'm using Firefox's web developer addon to play around with a page I'm developing. Initially, I had this file (print.html) just sitting on my desktop for easy access, as well as a directory called "images", to which I was linking images in my CSS and HTML. I since moved both the print.html file and the "images" directory to a sub-directory within my hard drive - both into the same subdirectory - but now the images just don't show up. When I hover over an image link and look at the status bar in my browser window, I see the path of the original location of these files (my desktop). But that's nowhere in the code - the link path is relative.

    The image path in my HTML is like this:

    <img src="images/print_c.jpg"

    Am I missing something here? If both the HTML file and the images directory are within the same enclosing directory, shouldn't the path be relative like this?

    Duh...

  2. #2
    Join Date
    Feb 2006
    Location
    Salisbury UK
    Posts
    4,332
    Links to an html file in the same folder (directory) can be simply inserted between the tags as filename.html .

    If the file is in a different folder the code is more complicated. For every movement to a lower level add / before filename.html or folder name (but not when accessing a folder or filename in the same folder); for every movement up add ../

    Consider the following folder arrangement:-

    folder1------->folder2------>folder3
    folder1------->folder4
    folder1 has another folder4 in it as well as folder2.

    Assume your html file is in folder2.

    If the target file is in folder3 - directly below folder2 - the link code has to go directly down so the link will be:-

    <a href="folder3/filename.html">

    If the target file is in folder1 - directly above folder2 - the link code has to go directly up so the link will be:-

    <a href="../filename.html">

    If the target file is in folder4 the route is up to folder1 then down to folder4; the link code will be:-

    <a href="../folder4/filename.html">

    Play around with the options until you get it right.
    Code downloaded to my PC will be deleted in due course.
    WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
    Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •