473,699 Members | 2,215 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 1473
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
1841
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 they should set the permissions to allow a sensible folder structure -
3
7705
by: Bill Brother | last post by:
Is it possible to retrieve the local full path of an image ( not the url )?
8
6677
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 Domain accounts for anonymous access (based on the application). - These domain accounts have all of...
385
17179
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 one are
15
11544
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 .BAT file and implement it with no path. Something about MSACCESS being a registered application.
6
1708
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. Entry has been placed in registry in
4
1889
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. What I'd like to do is have the client add a Virtual Directory in IIS under the project web directory...
1
1385
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 XmlTextWriter("\\Server2\wwwroot\SiteRoot
0
8700
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9184
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8931
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8892
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7767
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6539
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5878
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4386
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2359
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.