How to add parameters to a URL that already contains other parameters and maybe an anchor
<p>I'm wondering how I can add a new parameter to an existing url.
The problem is: the url may also contain an anchor. </p>

<p>For example:</p>

<pre><code>http://www.example.com?foo=bar#hashme
</code></pre>

<p>And I want to add another parameter to it, so it results in this:</p>

<pre><code>http://www.example.com?foo=bar&amp;x=y#hashme
</code></pre>
