Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

javascript code that get the included script path

Posted on 2003-03-12
7
Medium Priority
?
165 Views
Last Modified: 2013-11-18
I have html file like this:

<HTML>
    <HEAD>
        <script Language="JavaScript" Src="xxxx/yyyy/zzz.js"></script>
    </HEAD>
    .
    .
    .
</HTML>

I also have the included JavaScript file "zzz.js" in xxxx/yyyy folder.

My question:
is there any javascript code that will be inside the included file "zzz.js" that gets the path name ("xxxx/yyyy") ?
location.href will not work, because it's related to the whole document url and not to the included script url

it should support JavaScript 1.2 and IE browsers.

Thanks
0
Comment
Question by:Ugi_Fletzet
7 Comments
 
LVL 1

Expert Comment

by:chapatti
ID: 8122480
Hi Ugi_Fletzet,

What are you trying to do?
Maybe I can come up with a work-around.

TTFN,

chapatti
0
 

Author Comment

by:Ugi_Fletzet
ID: 8123264
Hi chapatti,
i need a piece of javascript code (that will be inside the included .js file) that will return the path of this .js file.
"var path=location.href" will not work, because this will return the path of the parent html file and not the path of the included js file.
I'm sure there is an easy way to find it.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Ugi_Fletzet
ID: 8123573
I found the answer by myself...

the answer is: document.scripts(x).src
where x is the id of the script or the index of the script.

for example, I need to change the html file to:
<HTML>
 <HEAD>
   <script Language="JavaScript" Src="xxxx/yyyy/zzz.js" id="qqq"></script>
   </HEAD>
   .
   .
   .
</HTML>

and later in the .js file I can do like that:
var path=document.scripts('qqq').src

Now, I need to give that points back to myself, but unfortunately, I think that I can't do that. if anyone know how can I do that, please tell me.
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 8124200
Just go to 'Community Support' (2nd last topic on the left menu) and post a question requesting this question be deleted and points refunded.
0
 

Author Comment

by:Ugi_Fletzet
ID: 8124253
thanks
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8124359
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question