I could be wrong, but I think you'd need to use something like php. Then you could use $_GET to get the variables from the url and print a 'window.onload' event on to the page to make it do what you want to do. That's what I'd do, though as I say, there might be a better way.
simlarly, is there a $_SET?
To have a script activate after the page has finished loading you need to attach it to the documents onload script. The simplest method is:
Where the function myscript() is defined within <script> tags or an included js file somewhere else.
You can access the url used to access the page via a couple of methods.
I don't know if the url returned will include the fragment identifier (that's the #someid) and the query string (that's the ?key1=value1&key2=value2 bit) in all browsers. FF and IE certainly do.
With those two bits of knowledge you should be able to extract the fragment identifier (or query string) value from the URL and have your script take whatever action it needs.
I am not certain what events fire in response to a "goto #fragment". Its possible the element may receive focus if its capable of receiving focus. In which case you could attach something to an onfocus event. Then again, maybe that's not how things work.