[Javascript] Callback to script-tag from included script?

Hakan Magnusson (Backbase) hakan at backbase.com
Wed Aug 18 10:38:34 CDT 2004


Hi Peter,

The goal is to read attributes from the script tag itself. I am actually 
free to add (some) attributes (non-html if I wish) to the script tag, 
but nothing else.

> Are you trying to provide a script that other people can use and
> have it tell you where it's running?

I think you got it head on here. The location of the included script is 
exactly what I want. ANY property would be even better, but if this can 
be accomplished, I'm happy for now.

I'm thinking about adding an id to the script tag, and then using 
document.getElementById(), since I think that would work on all targeted 
browsers. This is a far more ugly looking solution that I had hoped for, 
  but my initial experiments gave me nothing.

Regards,
H

Peter Brunone wrote:

> H,
> 
> 	What's the (non-technical) goal here?
> 
> 	Are you trying to provide a script that other people can use and
> have it tell you where it's running?
> 
> Peter
> 
> -----Original Message-----
> From: javascript-bounces at LaTech.edu
> [mailto:javascript-bounces at LaTech.edu] On Behalf Of Hakan Magnusson
> (Backbase)
> 
> When using external scripts, does anybody know of a way to get a 
> reference to the script tag that included the script?
> 
> -- Example, HTML:
> 
> <link type="text/css" rel="stylesheet" href="css/default.css" /> <script
> type="text/javascript" src="external.js"></script>
> 
> -- The file external.js:
> 
> // Should alert "css/default.css"
> alert(tagSelf.previousSibling.getAttribute('href'));
> 
> --
> 
> I am not interested in solutions that involve setting variables or 
> running scripts anywhere but inside external.js, the HTML must remain 
> completely clean.
> 
> Also, it must be a reasonable solid way of doing it in both IE and
> Mozilla.
> 
> Regards,
> H
> 
> 
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 



More information about the Javascript mailing list