Solved

path to a graphic.....

Posted on 2003-11-03
6
195 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Auto Complete Using JQuery 5 80
PHP email variable syntax 3 49
Grunt No Clean Targets 6 149
Facebook React and SyntheticEvents 6 64
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
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…
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

785 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