如何不刷新就打开新页面 [英] How to open new page without refresh

查看:84
本文介绍了如何不刷新就打开新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Rails应用程序,试图打开一个新页面,所有静态页面都是https://www.mazzey.com/链接,如果单击标题按钮,它将打开带有淡入和淡出的新页面不会在Mozilla Firefox中刷新页眉和页脚,但在Google Chrome中页眉也会刷新.我还发现该页眉和页脚也可以在Firefox中刷新,但这与Google Chrome并没有什么不同.那么我可以使用Ajax或任何插件来避免刷新页眉和页脚吗?

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 ?

推荐答案

$(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");
});

这是我与ba-hashchange插件一起使用的

This what I am using with the ba-hashchange plugin

有关更多信息,请检查此 css-tricks.com/video-screencasts/85-best-practices-dynamic-content/

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

这篇关于如何不刷新就打开新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆