改变页面的网址无需刷新页面 [英] changing page url without refreshing page

查看:91
本文介绍了改变页面的网址无需刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这甚至可能吗?

下面的问题:

我有一个关键字搜索与此URL(搜索之后):的http://本地主机/ THI /搜索?关键字=键

I have a keyword search with this URL(after searching) : http://localhost/thi/search?keyword=key

然后,我有一个滑块的搜索,它使用当作ajaxForm插件(jQuery的)...

Then I have a slider search which uses the AjaxForm plugin (jquery)...

当我执行滑盖搜索,很明显,我仍然会在关键字搜索URL(因为请求是通过AJAX发送)

when I perform a slider search, obviously I will still be in the keyword search URL (because the request is sent via ajax)

有没有办法改变目前的网址类似的http://本地主机/ THI /搜索?价格= 100 (滑块通过GET以价格作为提交一个GET变量)

Is there a way to change the current url to something like http://localhost/thi/search?price=100 (the slider submits via GET with price as a GET variable)

我想这样做,因为我想从滑块搜索结果进行书签...或者是有这样做的任何其他方式?

I wish to do so because I want the search results from the slider to be bookmarked...or is there any alternative way of doing this?

推荐答案

您可以使用哈希的URL(搜索#价格= 100) window.location.hash 的方法。这些将得到书签及用户可以通过这些导航与后退和前进按钮。

You can use hash urls (search#price=100) with window.location.hash methods. These will get bookmarked and user can navigate through these with back and forward buttons.

用法示例:

<a href="#">100</a>

$('a').click(function() {
    window.location.hash = 'price='+$(this).html();
    return false;
});

将设置链接直接搜索#价格= 100 无刷新。

这篇关于改变页面的网址无需刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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