Danny wrote:
Yes :
document.getElementsByTagName('script')[0].src
bear in mind that, [0], refers to the 1st <script....> ...
</script> element in the page. you
could also address it by means of id
<script .... src="somepath/something.js" id="someid">
document.getElementById('someid').src
Danny
Thank your for this information. Now I'm a little clearer about what I need,
as such, I wonder if the following may be possible?:
First of all, a simple script include tag would exist:
<script src="http://somedomain.com/something.js" id="Click here"></script>
Can the "id" be converted into a variable string within something.js and
later become a "linked_text" in the document.write html-output, as follows:
/* start (of an oversimplied version) of something.js */
var linked_text = somehow suck in the "id" of this include file;
d.write('<a href="..." onclick="anotherfunction();">'+linked_text+'</a>')
/* end of file */
Naturally the text_link variable could easily be passed via a standard
on-page javascript function above the include call, but the usage of the
script will be cross-domain, for site visitors to include a link to a
function on their websites, and be able to specify the linked text string,
but they cannot modify the external something.js file.
These site visitors are not necessarily half-knowledgable in js or html
either, so the shorter the code of the include, the better, i.e. one
include would be better than having one function containing only a variable
plus the include itself, i.e. I'm trying to find a one-liner solution.
Furthermore, would it be possible to re-use the include on the same html
page several times, with possibly different or sometimes even the same "id"
or linked_text, or would the function name conflict? On second thoughts,
maybe doing it the "id" way holds more trouble ahead than other methods...