//1. popular (incorrect) way to find URI for current script (inside the script code)
var script_src = (scripts = head.getElementsByTagName("SCRIPT"))[scripts.length - 1].src;
//2. popular trick to "resolve" uri to another script in the same "directory"
// src becomes:
// which is then transformed by browsers in actual http request to
however when combined together, it can turn deadly in Cross-Browser code
since .src returns "dots removed" in FF
and raw value in MSIE 7.0
So here comes the another magic constant 4 in getAttribute("src",4) for MSIE ;-), but ? it does not work ?! (now tested in MSIE 8)
so you have to use .src !
As far as I know even jQuery does not have fix for this,
even if they have for getAttribute("href",2)
Edited in 2011:
Confused ? me as well. I have to retest all this because MSIE 8 seems to somehow work with .src and not work with getAttribute("src,4").
Work means returning "expanded" and "normalized" uri.