I have a unique javascript code hosted on my server. I want to offer website visitors a similar implementation approach to Google Analytics where they can easily embed the script on their servers. For instance:
<script type="text/javascript" src="http://www.somedomain.com/script/script.js?id=2001102"></script>
Everything is functioning smoothly except for one key piece: extracting the id value. I've attempted using both location.href and location.search, but these methods only return the URL along with parameters from the embedding file, not "script.js?id=XSOMEIDX"
In my script.js file, I currently have:
function requestContent() {
var script = document.createElement("script");
script.src = "http://www.somedomain.com/script/xss_script.php?id="I WANT TO INPUT ID HERE+"&url="+location.href;
document.getElementsByTagName("head")[0].appendChild(script);
}
Can anyone provide guidance on how to extract the id value (e.g., id=XSOMEIDX) and insert it into xss_script.php?id=?
Many thanks in advance!