Skip to content

Instantly share code, notes, and snippets.

@jerryharrison
Created December 12, 2012 16:53
Show Gist options
  • Save jerryharrison/4269462 to your computer and use it in GitHub Desktop.
Save jerryharrison/4269462 to your computer and use it in GitHub Desktop.
Javascript: Grabbing the hash from the location.href and targeting a specific state on a page.
// auto open the album
var hash = window.location.hash.toString().replace('#','').split('-');
if(hash != ''){
// console.log(hash);
if (hash[2] != undefined) {
// console.log('Loading collection: ' + hash[1] + ' width image ID: ' + hash[2]);
getCollectionModalWithImage(hash[1],hash[2]);
$("#CanvasGrid li#Collection-" + hash[1] + " div").click();
} else if (hash[1] != undefined) {
// console.log('Loading collection: ' + hash[1]);
$("#CanvasGrid li#Collection-" + hash[1] + " div").click();
} else {
// console.log('Loading page: ' + hash[0]);
$(".menu a." + hash[0]).click();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment