Created
July 16, 2013 20:09
-
-
Save andershaig/6012209 to your computer and use it in GitHub Desktop.
Use window.location.hash to create an extra page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(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(); | |
| } | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For this example, you would create your new page in
#section-1and wrap all the existing content in#section-2, then set both todisplay: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).