Solved

path to a graphic.....

Posted on 2003-11-03
6
196 Views
Last Modified: 2010-04-06
I have created a 500 error page that gets called whenever the error occur. As usual it can be called from ANYWHERE on my webpage. The only proble I have is that I would like to display a graphic on this page but because the page being called from any place make it difficult to point the path to the graphic.

I don't want to use the full refference to the site everytime like http://www.abc.co.za/images/abc.gif

Is there any other way to make this reference dynamic?
0
Comment
Question by:beneke
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:DoppyNL
ID: 9670005
You can remove the domain from the url:

/images/abc.gif

If you're still in the same domain that will still work.

Otherwise you could write some code that would determine it's current location in relation to the images and build a relative url to the image.
I wouldn't write this code, only because the chance on an error on your site increases (more code, bigger chance for errors).

In short, why bother...
/images/abc.gif
works perfectly, isn't too long, and nobody would notice the way you are refering to the image. (unless they peak in the source ofcourse).
0
 

Author Comment

by:beneke
ID: 9670361
Hi DopyNL,

If the error page get called from the root the above image calling will work (image/abc.gif) Calling it from another directory(CGI) the above would not be true anymore and the image would not display. Now I need to change the reff to the image to ../image/abc.gif

0
 
LVL 6

Accepted Solution

by:
DoppyNL earned 250 total points
ID: 9670384
There are several ways to point to a file on a webserver:

1. absolute - "http://www.domain.tld/path/file.ext"
wich works allways

2. relative 1 - "../../path/file.ext"
relative to the current path; 2 down, 1 up ("path") the file "file.ext"

3. relative 2 - "/path/file.ext"
note the extra / in front!
that first / means that the path starts in the root of the domein --> actually "http://www.domain.tld" is put in front of it.
so, that should also work, even from your cgi-bin

remember that you are refering to files on the domain, not on the local filesystem (give it a try).
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 11

Expert Comment

by:Zontar
ID: 9675576
Doppy's "Relative #2" is also referred to as "root-relative".
0
 
LVL 6

Expert Comment

by:DoppyNL
ID: 9676650
>> Doppy's "Relative #2" is also referred to as "root-relative".

Cool, it has a name :)    ;)

And yet another thing learned... :)
0
 

Author Comment

by:beneke
ID: 9678096
Hi DopyNL,

Your third option, "root-relative" did the thing for me. Thanks a lot!

Regards
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question