jQuery的阿贾克斯+散/历史,更 [英] jQuery + Ajax Hash / History and more

查看:159
本文介绍了jQuery的阿贾克斯+散/历史,更的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让使用URL散列在jQuery来控制历史阿贾克斯,并链接/页的书印刷用一个手柄。我已经试过几乎所有的插件在那里,我似乎无法得到任何正常工作,所以我没有任何code的例子真的。但我愿意接受任何建议,资料,教程等。

I am trying to get a handle on using URL hashes in jQuery to control history in Ajax and make links / pages book-markable. I have tried almost every plug-in out there, and I cant seem to get any to work properly, so I dont have any code examples really. But I am open to any suggestions, information, tutorials, etc.

这是我想将其纳入一个网页不同的是,我有一个jQuery的动画驱动飞溅/加载页面,这也是所有的内容将被加载到同一个页面。

The difference on one of the pages I am trying to incorporate this into is that I have a jQuery animation driven splash/loading page, which is also the same page that all of the content will be loaded into.

..和该链路上,我要基于所述散列值/串绕过所有溅/加载动画的和直接加载内容(在这种情况下,#home)。

..and on this link, I want to by-pass all of the splash / loading animation and directly load the content based on the hash values / string (in this case, #home).

我一直在试图找出这一个了一段时间,任何帮助是极大的AP preciated,谢谢!

I've been trying to figure this one out for a while, any help is greatly appreciated, thanks!

推荐答案

那么,你有有问题的?设置散列标签或处理哈希的变化?

So what are you having problems with? Setting the hash tag or handling the change of the hash?

课程设置散列是简单地把哈希中的链接,例如℃的问题; A HREF =www.voidsync.com/2010/#page>链接< / A&GT ; 但我猜这不是你的问题。

Of course setting the hashes is simply a question of putting the hashes in links, for example <a href="www.voidsync.com/2010/#page">Link</a> but I'm guessing that's not your problem.

要真正做一些与哈希值,你必须有一个侦听器函数检查,例如每100ms有散列变化,采取相应的行动。一个简单的功能,可以是这样的:

To actually do something with the hash, you must have a listener function that checks for example every 100ms has the hash changed and acts accordingly. A simple function could go like this:

$(function() {
    var current_hash = false;
    setInterval(function() {
        if(window.location.hash != current_hash) {
            current_hash = window.location.hash;
            $('#content').load("content.php?page="+current_hash);
        }        
    }, 100);    
});

这(未经测试)函数将检查每100ms如果散列已经变了,如果有,则通过Ajax更新页面。

That (untested) function would check every 100ms if the hash has changed, and if it has, then updates the page via Ajax.

这功能也适用于页面加载,所以如果有一个链接页面上的用户登陆,如 www.voidsync.com/2010/#images ,该功能将加载页面影像自动。所以,历史和书签的作品。

This function also works on page load, so if user lands on the page with a link such as www.voidsync.com/2010/#images, the function will load the page 'images' automatically. So history and bookmarking works.

希望帮助,只是问,如果你的意思是别的东西。

Hope that helps, just ask if you meant something else.

这篇关于jQuery的阿贾克斯+散/历史,更的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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