473,573 Members | 2,922 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_whi te.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********@hotm ail.com
http://www.nathansokalski.com/
Jul 23 '05 #1
2 1470
Nathan Sokalski wrote on 02 mei 2005 in comp.lang.javas cript:
navrollovers[0]=new Image();
navrollovers[0].src="images/button_home_whi te.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_whi te.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_whi te.gif";

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

or, fully (for no good reason):

navrollovers[0].src="http://"+
location.hostna me+
"/images/button_home_whi te.gif";

Jul 23 '05 #3

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

Similar topics

10
1826
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. One ISP told me this couldn't be done - is IIS really that limited? I want to be able to suggest to my ISP (based on any advice you can give) how...
3
7703
by: Bill Brother | last post by:
Is it possible to retrieve the local full path of an image ( not the url )?
8
6674
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 applications work fine on IIS 4. Here is the scenario: - Mapped Drives on server to anotheer network Drive (I.E. - Q:\) - IIS uses different...
385
17036
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 extraneous jargons, such as in the Unix & Perl community. Unlike mathematicians, where in mathematics there are no fewer jargons but each and every...
15
11531
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 MSACCESS.EXE, tries them all, takes the first one it finds, and dies if none is found. Seems to me like at some time or another I was able to clone this...
6
1705
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 config is as follows: Windows XP Pro running IIS 5.1 Web app using integrated auth using a local user account Account has admin right over machine....
4
1885
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). I'm faced with having to do this without knowing where this PDF cache location is. It may be on the local drive, or it may be on a network share. ...
1
1383
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 Server1 and need to write RSS to a Server2 Something like this: Dim enc As Encoding = Encoding.UTF8 Dim objXMLTW As New...
0
8021
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8202
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7787
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6419
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5593
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5291
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3732
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3733
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1303
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.