Absolute path

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
jp50
Forum Newbie
Posts: 7
Joined: Sat Jun 07, 2008 6:19 am

Absolute path

Post by jp50 »

Hi to all,
I'm using absolute path for the images like
/img_folder/img.png
and it works fine in IE and Mozilla but not in Safari. If I change the absolute path in
C:/site-root/mysite/img_folder/img.png
then it works in IE,Safari but not in Mozilla.The question is: how can I use absolute path that is supported by the major browsers?
Thanks
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Absolute path

Post by jayshields »

Are you hosting/accessing the site locally?

You should specify absolute paths with the URL, not the drive letter.
jp50
Forum Newbie
Posts: 7
Joined: Sat Jun 07, 2008 6:19 am

Re: Absolute path

Post by jp50 »

I'm hosting this web site locally on a windows server 2003 IIS 6
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Absolute path

Post by pickle »

I think what ~jayshields was getting at was that this URL: "C:/site-root/mysite/img_folder/img.png" won't work for anyone that's not you.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
jp50
Forum Newbie
Posts: 7
Joined: Sat Jun 07, 2008 6:19 am

Re: Absolute path

Post by jp50 »

pikle,the server is on my computer therefore the root relative path /images/img.ping should work as well as the root absolute path which is C:/site-root/mysite/img_folder/img.png but it could be anywhere the site is stored.And it does workThe question was: why it's not recognised by all browsers the same?
bshultz
Forum Newbie
Posts: 2
Joined: Tue Jun 23, 2009 3:17 pm

Re: Absolute path

Post by bshultz »

Some browsers will interpret the path the folder based on where you launch the link from and others won't. If it is hosted locally and you launch the page from an 'open' command in a browser, say FireFox, it will know that it can locally reference the file. Ultimately it may be a problem when you post your site live and you should always try and use relative paths whenever possible.
Post Reply