Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • From: peter at brunone.com (Peter Brunone)
  • Subject: [Javascript] Callback to script-tag from included script?
  • Date: Wed Aug 18 10:26:08 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@xxxxxxxxxx
[mailto:javascript-bounces@xxxxxxxxxx] 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