Solved

path to a graphic.....

Posted on 2003-11-03
6
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Google adds suggestions 3 78
AngularJS directive issue 6 86
Make Line Items Look Good Over Mobile 2 127
MS Access VBA How To Properly Set Up A multipart/related HTTP Request 13 143
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…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

759 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