Skip to content

Instantly share code, notes, and snippets.

@andershaig
Created July 16, 2013 20:09
Show Gist options
  • Select an option

  • Save andershaig/6012209 to your computer and use it in GitHub Desktop.

Select an option

Save andershaig/6012209 to your computer and use it in GitHub Desktop.
Use window.location.hash to create an extra page
$(document).ready( function () {
if (window.location.hash === '#mySampleHash') {
$('#section-1').fadeIn();
// Change active nav item (optional)
$('#main_tab_my-sample-item').addClass('active');
// Change the page title to make it appear more like a different page
document.title = "My Sample Title";
} else {
// This is the default content for the page you're using
$('#section-2').fadeIn();
}
});
@andershaig
Copy link
Author

For this example, you would create your new page in #section-1 and wrap all the existing content in #section-2, then set both to display:none;.

After the JS executes, it will fade in the correct page based on whether the hash is present (thus giving them unique URLs to link to).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment