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

Peter Brunone peter at brunone.com
Wed Aug 18 10:30:25 CDT 2004


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






More information about the Javascript mailing list