Solved

path to a graphic.....

Posted on 2003-11-03
6
194 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with http basic authentication 5 97
IndexedDB how to clear the DB when returning but not refreshing? 1 151
Format results with PHP 3 68
Collapseable list of URLs. 10 112
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to count occurrences of each item in an array.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

932 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now