Advertisement

08.21.2008 at 02:25PM PDT, ID: 23668553
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Using JavaScript to find the current site's root path

Asked by rfiddler in JavaScript, Internet Explorer Web Browser

Tags: ,

Hi, I'm trying to find a way of retrieving the root path of the current site using JavaScript

The point is so that I can save it to a variable for use in JavaScript image references etc.

So far, my best idea is to assign an id to one of the <link> tags in the <head> which will always refer to a specific folder in the root of the site, and then use my script to check the path in the href attribute and remove the portion of the path after and including that folder.

This works beautifully in every browser except for Internet Explorer, of course.  :(
I've found that this is a known quirk in all versions of IE up to and including IE7.

Other browsers return a full, qualified URI, where IE returns a relative path which does not work with my script.  

So, can anybody tell me how I can check an element in the <head> that references an external file to find a full address, or otherwise any other way to return the root path of the current site?

I hope this makes sense.

Thanks!!

~RobStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
test.html:
------------------------------------------------------------------------------------
<link href="2008_templates/css/main.css" rel="stylesheet" type="text/css" media="all" id="mainCSS" />
<script type="text/javascript" src="../2008_templates/scripts/setPath.js"></script>
------------------------------------------------------------------------------------
 
setPath.js:
------------------------------------------------------------------------------------
var sSiteRoot = new String();
//sSiteRoot = "/main/_dev/ocotest3/";  //<-- hard-coding the site root path
 
setPath();
alert("sSiteRoot: " + sSiteRoot); //Testing
 
function setPath() {
  alert("link href: " + document.getElementById("mainCSS").href); //Testing
  alert("DocURL: " + document.URL); //Testing
   if (document.getElementById("mainCSS").href.indexOf("2008_templates")>0) {
    sSiteRoot = document.getElementById("mainCSS").href.substring(0,document.getElementById("mainCSS").href.indexOf("2008_templates"));
   }
}
------------------------------------------------------------------------------------
[+][-]08.21.2008 at 02:48PM PDT, ID: 22284638

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.

 
[+][-]08.21.2008 at 02:58PM PDT, ID: 22284714

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.

 
[+][-]08.21.2008 at 02:59PM PDT, ID: 22284721

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.

 
[+][-]08.21.2008 at 03:13PM PDT, ID: 22284815

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.

 
[+][-]08.21.2008 at 03:14PM PDT, ID: 22284823

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.

 
[+][-]08.21.2008 at 03:30PM PDT, ID: 22284934

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.

 
[+][-]08.21.2008 at 03:31PM PDT, ID: 22284942

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.

 
[+][-]08.21.2008 at 03:54PM PDT, ID: 22285067

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.

 
[+][-]08.21.2008 at 09:09PM PDT, ID: 22286545

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.

 
[+][-]08.21.2008 at 09:31PM PDT, ID: 22286705

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.

 
[+][-]08.21.2008 at 10:14PM PDT, ID: 22286979

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: JavaScript, Internet Explorer Web Browser
Tags: JavaScript, Internet Explorer
Sign Up Now!
Solution Provided By: hielo
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.21.2008 at 11:40PM PDT, ID: 22287371

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.

 
[+][-]08.22.2008 at 05:02PM PDT, ID: 22295021

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.

 
[+][-]08.22.2008 at 05:07PM PDT, ID: 22295032

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.

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