in reply to (OT) how to pass the URL itself to an embedded script
IE's DHTML/DOM is documented here.
The document object has a URL property, which would include GET arguments, but not POST arguments.
If you need POST arguments, the arguments could be included in the generated page as hidden fields (i.e. <input type="hidden" name="name" value="value">). Then your script can get the value of those hidden fields.
In Section
Seekers of Perl Wisdom