Ugi_Fletzet
asked on
javascript code that get the included script path
I have html file like this:
<HTML>
<HEAD>
<script Language="JavaScript" Src="xxxx/yyyy/zzz.js"></s cript>
</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
<HTML>
<HEAD>
<script Language="JavaScript" Src="xxxx/yyyy/zzz.js"></s
</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
Hi Ugi_Fletzet,
What are you trying to do?
Maybe I can come up with a work-around.
TTFN,
chapatti
What are you trying to do?
Maybe I can come up with a work-around.
TTFN,
chapatti
ASKER
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.
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.
ASKER
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.
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
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.
Just go to 'Community Support' (2nd last topic on the left menu) and post a question requesting this question be deleted and points refunded.
ASKER
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.irt.org/xref/Folder.htm
http://www.irt.org/xref/jscript_objects.htm
may help