views:

111

answers:

2

Hi everybody, I followed this great tutorial to"ajax" my blog:http://www.deluxeblogtips.com/2010/05/how-to-ajaxify-wordpress-theme.html But it creates some problems and I think the problem is in the hash that ajax creates. So, after the content is loaded, how can I remove the hash from the url? I copy my code here:

    jQuery(document).ready(function($) { 
    var $mainContent = $("#content"), 
        siteUrl = "http://" + top.location.host.toString(), 
        url = ''; 

    $(document).delegate("a[href^='"+siteUrl+"']:not([href*=/wp-admin/]):not([href*=/wp-login.php]):not([href$=/feed/]):not([href*=/go.php]):not(.comment-reply-link)", "click", function() { 
        location.hash = this.pathname;
$('html, body').animate({scrollTop:0}, 'fast');
        return false; 
    }); 

    $("#searchform").submit(function(e) { 
        location.hash = '?s=' + $("#search").val(); 
        e.preventDefault(); 
    }); 

    $(window).bind('hashchange', function(){ 
        url = window.location.hash.substring(1); 

        if (!url) { 
            return; 
        } 

        url = url + " #inside"; 

        $mainContent.html('<div id="loader">Caricamento in corso...</div>').load(url, function() { 
            //$mainContent.animate({opacity: "1"});
            scriptss();
        }); 
    });

    $(window).trigger('hashchange'); 
});

Thank all very much!

+1  A: 

So you want to remove the hash? Just set it to an empty string.

window.location.hash = '';

This will set your hashchange event, but it looks like you check and just return if the hash is empty.

artlung
and can check this as well http://stackoverflow.com/questions/2295845/remove-hash-without-page-jump/2295896#2295896
Amr ElGarhy
A: 

Thank you very much

Hi albyz, if an answer works for you you can vote it up and mark it as "accepted" -- the "Answers" section is not the right place for a "Thank you."
artlung