www.webdeveloper.com
Results 1 to 13 of 13

Thread: Why is html page not displaying

  1. #1
    Join Date
    Jun 2005
    Posts
    332

    Why is html page not displaying

    Hello, I have a little problem.

    What I want to understand first is:

    in when you are writing "/" in a source. example: "/files/file/file.jpg"

    Doesn't that mean that the file is stored on the same directory as the html file that is calling the jpg

    To clarify, say if I had an html file in a place like in my documents/htmlfiles/index.html

    And in the same directory I had another file called picture.jpg

    To call up that file in the html, do I just use "/picture.jpg"?

    I am asking you this, because I made an html file, and in the computer I use when I try to preview it, it can't display the images I have put on.

    But when I upload the webpage into another server, it does work.

    Does anyone know what the problem is?

    the webpage I have uploaded is here:

    http://goldenworldgoods.awardspace.com/

  2. #2
    Join Date
    Mar 2007
    Location
    Orlando
    Posts
    670
    No. When you use / or /picture.jpg you are telling the server that the file is located at root. Depending on you server configuration this could be the server root or the document root. In most cases I have run across it will be document root. For example, if you have a site foo.com which has a link <a href="/">Link</a> then this link would point to foo.com. <a href="/picture.jpg">picture</a> would resolve to foo.com/picture.jpg

  3. #3
    Join Date
    Mar 2006
    Location
    Newcastle NSW Australia
    Posts
    4,033
    If the picture is in the same folder as the html file, then using relative addressing you would refer to it as "picture.jpg" - the html and picture files can be both together in any folder of the site. "/picture.jpg" means the picture is in the root folder of the site, which in your case is true when uploaded, but not on your local machine. As an extra, if your pictures where in a folder called "images" and your html in the root folder, you reference it by "images/picture.jpg".

    edit: Damn, 1 minute too slow ....

  4. #4
    Join Date
    Jun 2005
    Posts
    332
    So your saying that I shouldn't put the slash in front of my sources, or otherwise, is there a simple way to do his without having to change the sources paths everytime I use my computer?

  5. #5
    Join Date
    Mar 2007
    Location
    Orlando
    Posts
    670
    If the file is in the document root, then use the slash. I like to have everything relative to the document root so I use it everywhere. So if my picture is in a directory called images then my url would be /images/pic.jpg

  6. #6
    Join Date
    Jun 2005
    Posts
    332
    So what is the document root, and where is it on my computer?

    Also this does not explain why another HTML page that I downloaded, also uses the same pathing ways, (always using "/") and it's working when I preview it.

    The other html page is located in the same place too, It is in however another folder...

    This site is the other site:

    http://solutionsdev.wmn.cc/

  7. #7
    Join Date
    Mar 2007
    Location
    Orlando
    Posts
    670
    The document root is whatever you specify it to be in the server configuration. ../phpBB2/index.php is VERY different from /phpBB2/index.php
    The first means one directory up from the current, then the phpBB2 directory. The second means that the phpBB2 directory is at the document root which may be /usr/www/phpBB2 or something like that.

  8. #8
    Join Date
    Jun 2005
    Posts
    332
    Ok

    So how do I configure my router?

    and

    If my HTML file is my documents on a windows pc,

    What Should I be using as my source?

  9. #9
    Join Date
    May 2005
    Location
    Northern Indiana
    Posts
    597
    Your router has absolutely nothing to do with any of this. What matters is your server. Likewise, the location on your computer has little to do with anything. If you want to be able to reliably preview your site on your computer, you should have a web server installed. In short, if you preview your file in the browser, and the address bar gives a local address (ex "C:\My Documents\myFile.html"), you can't rely on it being an accurate preview of how the site will behave on an actual file server. If you install a local web server, it would instead look like "http://localhost/myFile.html", and as far as your browser is concerned, it is an actual web site. When going that route, where the file is on your computer doesn't matter nearly as much as where your web server's directories are mapped.

    May I recommend starting off be reading some tutorials. The first would be something on relative links & how they work. This seems to cover the basics, but there may be other better ones:
    http://www.webreference.com/html/tutorial2/3.html
    As with anything else on the web, there is no one "right" way to do your links. There are multiple ways you can set them up, and without being able to see your site's layout, it is hard to say which is the best in your particular situation. If there is any question, you can always just use absolute links instead- they're not as flexible and require a little more typing, but they're a lot easier to figure out- especially if you're not good at mentally mapping out relative paths.

    Second, read up on web servers. You can install IIS, Apache or a variety of other servers on your local pc for testing, but you need to understand how they work first.
    Last edited by Tweak4; 07-23-2007 at 10:58 AM.

  10. #10
    Join Date
    May 2003
    Location
    Andover, UK
    Posts
    410
    It may not be relevent here, but check also that there are no issues with upper & lower case. MS software ignores case in filenames and paths, unix/linux servers are case sensitive. For example if your link say mypic.jpg and the picture is called Mypic.jpg, it may not be found.

  11. #11
    Join Date
    Jun 2005
    Posts
    332
    Ok thanks, I was just wondering if there was a link style that meant the file was in the same directory that the file was stored in

  12. #12
    Join Date
    Mar 2006
    Location
    Newcastle NSW Australia
    Posts
    4,033
    Quote Originally Posted by Dragonkai
    Ok thanks, I was just wondering if there was a link style that meant the file was in the same directory that the file was stored in
    I thought I answered that in my post above .........

  13. #13
    Join Date
    Jun 2005
    Posts
    332
    Yes you did

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles