javascript - Manually add Browser History Entry (Cross Browser) -
i don't know if it's possible in way achieve, want do. got single page website sections. this:
<div class="page pageone"></div> <div class="page pagetwo"></div> <div class="page pagethree"></div> <div class="page pagefour"></div> when open site, pages 2, 3 , 4 got display:none , first 1 display:block. when click link in navigation, current "page" fades out , whatever link you've clicked on, belonging section fades in. links this:
<a class="pagechange" href=".pagefour">four</a> and here's jquery code:
$(".pagechange").click(function(e){ e.preventdefault(); var href = $(this).attr("href"); $(".page").fadeout(200); settimeout(function(){ $(href).fadein(); }, 200); }); what's pretty obvious when click browsers back button, won't fade previous section in. return previous site i've opened.
so question is: there way add history entry in browser, when clicking on link? can press button , fades previous section in?
visible section before clicking link, i've done this:
var currentpage = $(".page:visible").attr('class').split(' ')[1]; but unfortunately that's no use want achieve.
i'd incredibly happy if provide me of how approach (or if it's possible)
you have use browser history api update url. can detect , forth movement onpopstate , call fadein , fadeout methods accordingly.
Comments
Post a Comment