I am setting up a script/div pair that can be posted on an EXTERNAL site so someone can view the content from MY site. It works fine where there is only ONE script/div pair on the page but when there are multiple instances, the parameters from the LAST instance are the parameters every instance uses.
For example I have:
<div id="1"></div>
<script src="script.js?id=1"></script>
<div id="2"></div>
<script src="script.js?id=2"></script>
<div id="3"></div>
<script src="script.js?id=3"></script>
But every instance of script.js gets the id "3". I'm using this bit of code to get the script URL:
var scripts = document.getElementsByTagName('script');
var thisScriptElement = scripts[scripts.length - 1];
var scriptPath = thisScriptElement.src;
It's clear the second line is the problem, but I have no idea how to fix this issue.