Hi Sam.

That sounds like a good compromise. I've never seen that method to get
the current scripts file name. Does it work in most browsers (inc IE
5.5+)?

Actually, after  a quick trawl through MSDN, I don't think the fileName property on Error objects is widely supported.
A possible (less hacky) alternative would go something like this:

new function(){
  var scripts = document.getElementsByTagName('script'), i = 0, script, match;
  while (script = scripts[i++])
    if (match = /#_jq_(.*)$/.exec(
script.src)) break;
  window[match ? match[1] : '$'] = jQuery;
};


... in this case using a prefix of _jq_ on the hash parameter, to make sure we are definitely seeing a jQuery script element.
I'd rather not have to walk the DOM to find the URL of the running script, but it still ought to be pretty reliable -- at least against false positives.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to