2013-08-06 68 views
0

我有两个选项卡的登录页面,当我在塔布我用js和更新DIV如何更改地址栏中的网址?

$.get("/users", function(data) {}); 

$('.userTable').html("<%= escape_javascript render(:file => 'users/index.html.erb') %> "); 

我如何更改地址栏还链接点击?每个选项卡都具有创建,编辑功能,这也是我使用ajax的功能。如何在地址栏中更改网址以创建和更新?我检查了一些railscast,但没有一个讨论crud。预先感谢您的帮助。

+0

[更新与新的URL地址栏没有哈希或重新加载页面(HTTP的可能重复:// stackoverflow.com/questions/3338642/updating-address-bar-with-new-url-without-hash-or-reloading-the-page) – Dhiraj

回答

1

您可以使用历史操作API:

//Change address to http://www.test.com/page.php: 
history.pushState('', '', 'http://www.test.com/page.php'); 

How do I do awesome refreshless page changes like GitHub do?https://github.com/blog/760-the-tree-slider

+0

所有浏览器版本是否支持pushState()方法,或仅支持最低版本的每个浏览器? – reporter

+0

http://stackoverflow.com/questions/3722815/does-internet-explorer-support-pushstate-and-replacestate – Ilyssis

+0

这是如何工作的?从哪里我会得到的URL在这里传递'history.pushState('','','从哪里??');' – user588324