I'm trying to pass a variable to a page. My code is as follows:

To link to a new page:
<a href="../gloss.htm" onClick="intercept(this)">Text</a>

Which calls the function:
function intercept(what) {
what.href += '?db=' + db; //adds the correct db scenario (?db=...) to the end of the URL
}

Essentially what happens is, the link becomes
../gloss.htm?db=abi

However, when I do this with a link to an anchor, it doesn't work.
I've put in alert boxes to show me the values, and they claim that the path is correct:
../gloss.htm#anchor?db=abi
but when it loads into the page it turns to
../gloss.htm?db=abi#anchor
and of course it doesn't go to the correct location on the page.

Is this a limitation of the browsers? Is there a way around it?