I am embedding a external js file on some domains and I need to get the current location of the their URL to send to the server before the script is rendered and not after. I need to this dynamically so I cannot have the user specify the url themselves. For example I have a script:
<script type="text/javascript" src="file.js?url=NEED THIS"></script>
I would love to simply replace NEED THIS with window.location.href, however sadly this would not work. The main problem is that I need to get the url and parse it on the server side to generate the content file.js will deliver so I need this url passed to file.js at the beginning. How can I achieve this without using a iframe?