Advertisement

07.26.2007 at 12:47AM PDT, ID: 22722056
[x]
Attachment Details

Get site domain within javascript

Asked by dealclickcouk in Scripting Languages, JavaScript

Tags: javascript, get, domain, path

The website I work with uses mod_rewrite to create nicer urls, but a result of this is that we have to put the full path to images etc within javascript include files.

I would like to avoid doing this, so that the include files can be easily transfered to different websites without the need for modifying them.

Eg
If scripts.js is included from the following URL:

http://www.domain.com/prodname/prodsub/name.php

The following code would not work:

var arrowheadimg=["./ukimgs/arrowdown.gif"] //path to down and up arrow images

as it looks for the image at http://www.domain.com/prodname/prodsub/ukimgs/arrowdown.gif

where as the image is actually in:

http://www.domain.com/ukimgs/arrowdown.gif

NB:  I can't just put  few extra ./../../ on the image reference as the script will be used by many pages that have different number of params from the mod_rewrite and so varying length.

Thanks

Start Free Trial
[+][-]07.26.2007 at 12:48AM PDT, ID: 19572514

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Scripting Languages, JavaScript
Tags: javascript, get, domain, path
Sign Up Now!
Solution Provided By: mplungjan
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.26.2007 at 12:50AM PDT, ID: 19572522

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 01:02AM PDT, ID: 19572578

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.26.2007 at 01:04AM PDT, ID: 19572586

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 01:43AM PDT, ID: 19572756

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 01:50AM PDT, ID: 19572788

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 02:03AM PDT, ID: 19572844

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 02:24AM PDT, ID: 19572918

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 02:40AM PDT, ID: 19572980

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 03:04AM PDT, ID: 19573068

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.26.2007 at 06:21AM PDT, ID: 19574119

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32