473,414 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Writing a full path without the domain

I have a rollover script that I plan to use for many of my pages. When I
preload the images, the directories must be relevant to the location of the
HTML file that uses the script, which will not always be the same. Because
of this, I figured the only way to place the script in an external file and
still have it work was to use full path names including everything after the
domain. For example, if my image was located in
http://www.mydomain.com/images/image1.gif, I would like to store the
directory as something like /images/image1.gif so that I have the entire
path entered but do not have to modify it when my domain changes. However,
Javascript does not seem to like the format I showed above. What can I do to
achieve this? The lines of code where this will be used currently look like
the following:

navrollovers[0]=new Image();
navrollovers[0].src="images/button_home_white.gif";

As you can see, the second line will not work for HTML files in directories
other than the root. What should the code look like? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Jul 23 '05 #1
2 1459
Nathan Sokalski wrote on 02 mei 2005 in comp.lang.javascript:
navrollovers[0]=new Image();
navrollovers[0].src="images/button_home_white.gif";

As you can see, the second line will not work for HTML files in
directories other than the root. What should the code look like?
Thanks.


navrollovers[0].src="/images/button_home_white.gif";
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2
Lee
Nathan Sokalski said:

I have a rollover script that I plan to use for many of my pages. When I
preload the images, the directories must be relevant to the location of the
HTML file that uses the script, which will not always be the same. Because
of this, I figured the only way to place the script in an external file and
still have it work was to use full path names including everything after the
domain. For example, if my image was located in
http://www.mydomain.com/images/image1.gif, I would like to store the
directory as something like /images/image1.gif so that I have the entire
path entered but do not have to modify it when my domain changes. However,
Javascript does not seem to like the format I showed above. What can I do to
achieve this? The lines of code where this will be used currently look like
the following:

navrollovers[0]=new Image();
navrollovers[0].src="images/button_home_white.gif";

navrollovers[0].src="/images/button_home_white.gif";

or, fully (for no good reason):

navrollovers[0].src="http://"+
location.hostname+
"/images/button_home_white.gif";

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Kenny Ashton | last post by:
Hi all Can anyone tell me the best way to set permissions to allow an ASP program to write new Html pages to my site's root folder, without chancing users also being able to write to the root....
3
by: Bill Brother | last post by:
Is it possible to retrieve the local full path of an image ( not the url )?
8
by: Matt | last post by:
I am migrating from NT 4.0 (IIS 4) to 2003 Server (IIS 6). Our Intranet has numerous applications that utilize the FileSystemObject (FSO) and each one is returning a "Path not found." error. These...
385
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like...
15
by: (Pete Cresswell) | last post by:
I've got a .BAT file that I use for executing various MS Access apps that I wrote way back in the days of 2.0. It's evolved over time, but it still contains a number of possible paths to...
6
by: MattC | last post by:
I have some code that correctly writes to the eventlog on my local machine. I have installed the application on the Live server and all is not well, no event log entries. My development box...
4
by: William Sullivan | last post by:
I have an application that pulls images from a physical drive directory, creates a PDF of the image, caches the image, and returns a link to the client (using ajax, but that's not the problem). ...
1
by: pxpilot | last post by:
HELP! I know there's a lot of urls out there, please don't reply with a link. I have tried them all but i guess i am missing something. I have 2 servers on the same network, my ASP.NET runs on...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.