How to make a URL link to another state of the page? <p>I'd like to share a page in a state when the second link is active (e.g. "http:/ /mypage#green-color"). </p> <p>I tried to add to the second link <code>onClick="window.location='#green-color';"</code> attribute. It changes the URL in the browser's address window, but I can't share it with others.</p> <p><a href="http://jsfiddle.net/Rk3Xz/1/" rel="nofollow">code in JS Fiddle</a> </p> <pre><code>&lt;a href="#" id="all"&gt;All Colors&lt;/a&gt; &lt;a href="#green" id="green-color"&gt;Green Color&lt;/a&gt; &lt;div id="red"&gt;&lt;/div&gt; &lt;div id="green"&gt;&lt;/div&gt; </code></pre> <p>Two states of the page:</p> <pre><code>$( "#all" ).click(function() { $( "#red" ).show(200); }); $( "#green-color" ).click(function() { $( "#red" ).hide(200); }); </code></pre>