Reputation: 8754
I insert an external .js file from another domain. Like this:
<script src="http://externaldomain.com/file.js" type="text/javascript"></script>
file.js is always the same, but it can be placed in different domains,
so I need to know what is the source of the file.
For example: file.js is in domain1.com, domain2.com and domain3.com.
If someone insert it like this: <script src="http://domain1.com/file.js" type="text/javascript"></script>
I want to know that the file is inserted from domain1.com
How to do it?
Upvotes: 1
Views: 988
Reputation: 1039248
There's no reliable way of achieving this. Basically inside this file you will need to parse the DOM, search for all the <script>
tags and when you find the one that corresponds to the inclusion of this javascript file parse the src
attribute to extract the domain.
Upvotes: 4