0

I'm currently writing a jQuery plugin that I'd like to host on my site for others to use and include.

How do I get the hostname root of the plugin's location?

<script type="text/javascript" src="http://myhost.com/scripts/myplugin.js"></script>

I was wondering how myplugin.js would be able to retrieve it's OWN location's hostname despite being possibly included on another website. So if one would include that script source on their website, myplugin.js would still be able to retrieve http://myhost.com

This would make. window.location an invalid choice right?

Max Alexander
  • 5,471
  • 6
  • 38
  • 52
  • 1
    don't think it's possible. Guess you could traverse the elements inside `` to find the script with the `src` you want, but I believe this is not very consistent across browsers – Rodolfo Jun 19 '12 at 19:53
  • 1
    make sure it works in all browsers. I remember like a year ago I thought I could traverse the elements in `` and it worked in Firefox, but then tested in other browsers (or maybe in like IE7) and in there it didn't work, as the browser didn't report the whole thing or something, don't remember exactly. – Rodolfo Jun 19 '12 at 21:01

0 Answers0