chordsoflife Posted July 18, 2009 Share Posted July 18, 2009 I'm really struggling with this, mostly because I don't know JS very well. If anyone can tell me anything to lead me in the right direction, it would mean the world. Here's the code: function pageload(hash) { alert("function ran"); if(hash) { alert("function true"); $(".page01").hide(); $(".page02").hide(); $(".page03").hide(); //$("." + hash + "").show(); } else { alert("function false"); $(".page01").hide(); $(".page02").hide(); $(".page03").hide(); } } $(document).ready(function(){ $.history.init(pageload); $("a[@rel='history']").click(function(){ var hash = this.href; hash = hash.replace(/^.*#/, ''); alert(hash); }); }); It should be pretty clear what I'm trying to do (and alerts to see if I can figure out what's happening when), but I'll explain: I have three divs on a page, and up top there's a navigation (page 1 2 3). Each link hides two and shows only one page. Each page has about ten links to other pages. When I click to an individual page, I want to be able to click the browsers back button back to whichever "page" (1, 2 or 3) I was on. Thanks! Link to comment https://forums.phpfreaks.com/topic/166399-solved-jquery-history-help/ Share on other sites More sharing options...
chordsoflife Posted July 18, 2009 Author Share Posted July 18, 2009 Hm. I actually figured it out on my own (+1 for life). Here's what I wound up doing in case anyone is interested.. not extremely versatile though. $(document).ready(function(){ function pageload(hash) { $(".page01").hide(); $(".page02").hide(); $(".page03").hide(); if(hash) { $(".page0" + hash + "").fadeIn(); } else { alert("else."); $(".page01").fadeIn(); } } $(".page02").hide(); $(".page03").hide(); $.historyInit(pageload); }); Link to comment https://forums.phpfreaks.com/topic/166399-solved-jquery-history-help/#findComment-877477 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.