I have written a code ( => just for myself usage) that makes links bookmarks like this example:
you are on : "http://www.mysite.com/index.php" you click a link like "sitemap.php" it will be load and you will see "http://www.mysite.com/ index.php#sitemap" or if you click "myfile.php?id=3&p=test" it load and you will see "http://www.mysite.com/index.php#myfile:id=6/ p=test/" this code dosn't change any anchor href and i think this is why this code is better than others for me ( for seo ) you can see the example on " http://www.giftcenter.ir " and js file on : "http://www.giftcenter.ir/templates/Gift/js/js.js" $(document).ready(function(){ $("a").livequery('click',function(){ var h = $(this).attr("href"); history(h); $.get(h,function(){} ); }); }); var getHash = function(myHash){ h = myHash; if ( h.length < 1) h = 'index'; if ( h.indexOf(':') > 0 ){ h = h.replace(/^#/,'').replace(':','.php?'); while( h.indexOf('/') > 0 ) h = h.replace ('/','&'); }else { h = h.replace(/^#/,''); h += '.php'; } // this line will run when you have load a page before and now you are refreshing the page.... $.get(h,{'ajax_check':'true'},function(data){$body.html ('<center>' +data + '</center>');}); if($.browser.msie) _loadedHash = _historyIframe.contentWindow.document.location.hash; else _loadedHash = myHash; }; if ($.browser.msie) { var _historyIframe = $('<iframe style="display: none"></ iframe>').appendTo("BODY").get(0); var iframe = _historyIframe.contentWindow.document; iframe.open(); iframe.close(); setInterval(function(){ var h = _historyIframe.contentWindow.document.location.hash; if ( (_loadedHash != null) && ( _loadedHash ! = h) ) getHash(h); }, 500); } else if ($.browser.mozilla) { setInterval(function(){ if ( (_loadedHash != null) && ( _loadedHash != location.hash) ) getHash(location.hash); }, 500); } try{ if(location.hash.length > 0 && !$.browser.msie) getHash(location.hash); }catch(e){ alert(e.name + ' ' + e.message); } var history = function(path){ var qmp = (path.indexOf('?') > 0 ) ? path.indexOf('?') + 1 : path.length + 1; var lp = path.length; var fileNameP1 = path.indexOf('.php') + 1; var fileNameP2 = (qmp > 1) ? qmp-1 : path.length; var params = path.substring(qmp,lp); var newPath = ''; var fileName = path.substring( path.substring (0,fileNameP2).lastIndexOf('/')+1 , fileNameP2 ).replace('.php',''); if (params.length > 0 ){ var a = explodeArray(params,"&"); for (var i=0, j=a.length; i<j; i++) newPath += a[i] + '/'; newPath = '#' + fileName + ':' + newPath; } else { newPath = '#' + fileName; } if ($.browser.msie) { var iframe = _historyIframe.contentWindow.document; iframe.open(); iframe.close(); iframe.location.hash = newPath; } location.hash = newPath; _loadedHash = newPath; }; On Dec 18, 10:06 pm, relphie <relp...@gmail.com> wrote: > Hello, I was wondering if anyone has successfully combined jQuery ajax > calls with a browser history plugin. I have seen lots of older posts, > and lots of older libraries, but not many examples for a current, > cross-browser solution. I have tried using Really Simple History > (http://code.google.com/p/reallysimplehistory/), and while it does add > the anchor pages to my history, the content remains the same when > going forward / backward. I also tried the JSSM plugin (http:// > trac.nathanhammond.com/jssm/), I had to hack it up a little bit since > it tries to be all-in-one, but I had the same problems with it as with > RSH (history is there, but it doesnt do anything). > > The history plugins listed in the jQuery plugins directory I have also > tried and the are either old, not up-to-date with current browsers, or > not fully functional. > > Does anyone have a working example that they could point me to? Any > advice on how to integrate with one of the plugins I mentioned? Any > ideas as to why the history is there, but the page content does not > change? > > Here are the ajax calls I would like to create a history for: > > <code> > function ajaxMenu() { > $("#accordion .ui-accordion-data a").click(function(event) { > event.preventDefault(); > $(".userTool").html("").append("<div id='loading' > class='loading' > style='margin-top:7em;'><img alt='loading...' src='../images/ajax- > loader.gif'></div>"); > var url = $(this).attr("href"); > if(url.indexOf("?") == -1) { > url = url + '?'; > } else { > url = url + '&'; > } > url = url + 'ajax=true&skipNavigation=true'; > $.ajax({ > url: url, > complete: function(XMLHttpRequest, textStatus) { > > $(".userTool").replaceWith(XMLHttpRequest.responseText); > $(".filtered",".userTool").columnFilters(); > } > }); > $("#accordion .ui-accordion-data a").removeClass("current"); > $(this).addClass("current"); > });} > > </code>