How to open new page without refresh

时光怂恿深爱的人放手 提交于 2019-12-25 02:23:13

问题


I am using a rails application, in which I am trying to open a new page, all the static page, https://www.mazzey.com/ is the link, if you click on the header buttons, it opens new page with fade in and fade out effect with the header and footer without refreshing in Mozilla Firefox but in Google Chrome the header also refreshes. I also found that that header and footer refreshes in Firefox as well but it does not that unlike Google Chrome. So can I use to Ajax or any plugin to do that to avoid refresh of header and footer ?


回答1:


$(function(){
    var newHash      = '',
        $mainContent = $("#main-content");
    $(".nav").delegate("a","click",function(){
        window.location.hash = $(this).attr("href");
        return false;
    });
    $(window).bind('hashchange',function(){
        newHash = window.location.hash.substring(1);
        if(newHash){
            $mainContent.find("#guts").fadeOut('slow',function(){
                $mainContent.hide().load(newHash + " #guts",function(){
                    $mainContent.fadeIn('slow');
                });
            });
        }

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

This what I am using with the ba-hashchange plugin

for more information check this css-tricks.com/video-screencasts/85-best-practices-dynamic-content/



来源:https://stackoverflow.com/questions/20026731/how-to-open-new-page-without-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!