Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>According to your structure, this should make your friendly hashes:</p> <pre><code>var pathname = $(this).find('a')[0].href.split('/'), l = pathname.length; pathname = pathname[l-1] || pathname[l-2]; window.location.hash = "#!" + pathname; </code></pre> <p><a href="http://jsfiddle.net/e7E73/1/" rel="nofollow"><strong>Demo</strong></a> <hr> Now to make the URLs shareable, you will need to execute a hash check on DOM ready and load the corresponding content.</p> <p>If all the pages are in the same directory, you can do it directly:</p> <pre><code> $(function() { var hash = window.location.hash; //checks if hash exists and is hash bang if (hash &amp;&amp; hash.substring(0, 2) === '#!') { hash = hash.substring(2); //removes leading #! $('#content').load('path/to/' + hash); } }); </code></pre> <p><a href="http://jsfiddle.net/e7E73/3/show/#!test5" rel="nofollow"><strong>Demo</strong></a></p> <p>If the pages aren't all in the same directory, you'll need to map the hashes to the addresses.</p> <pre><code>$(function() { var hashmap = { 'test5': 'http://foobar.baz/fooz/test5', 'anotherTest': 'http://foobar.baz/barz/anotherTest', }; var hash = window.location.hash; //checks if hash exists and is hash bang if (hash &amp;&amp; hash.substring(0, 2) === '#!') { hash = hash.substring(2); //removes leading #! if (hashmap[hash]) { //checks if hash exist in the hash map $('#content').load(hashmap[hash]); } } }); </code></pre> <p><a href="http://jsfiddle.net/e7E73/8/show/#!test5" rel="nofollow"><strong>Demo</strong></a></p> <p>I'm using alerts in the demos above as the loading will fail. Of course you have to adapt/replace the <code>$('#content').load</code> by your preferred load method.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload