是否有可能在某些事件中更改地址栏或浏览器中的URL更改 [英] is it possible to change change the url in address bar or browser on certain event
问题描述
你们都使用了pinterest,你可以看到当你点击任何pin时,div被添加并且lightbox显示在同一页面上,但url被改变为实际pin页面的值。我有相同的灯箱显示数据,是否有可能改变这样的网址?..
you all have used pinterest, you can see that when you click on any pin, a div is added and lightbox is shown on the same page but the url is changed to that of actual pin page. i have the same lightbox to show data, is it possible to change the url like that?..
我想告诉的一件事是,我有链接哪调用view()方法的onclick事件,其中我使用ajax请求调用另一个页面,该页面显示页面上的内容,当点击此链接时我想更改url,并在关闭时返回到上一个url。这里是我的代码
one thing i want to tell is that, i have link which has onclick event which calls view() method, in which i am calling another page with ajax request, which shows the content of that page on my page, i want to change url when this link is clicked and back to previous url when closed..here is my code
function view(){
$.get('mypage.jsp', function(html) {
$(html).hide().appendTo('body').fadeIn(500);
}, 'html');
};
推荐答案
此功能被称为 HTML5推送状态。这里有一个相关的StackOverflow问题,可以提供更多的见解。 使用HTML5 History API的好教程(Pushstate?)
This feature is known as HTML5 Push State. Here's a related StackOverflow question which may provide more insight. Good tutorial for using HTML5 History API (Pushstate?)
这篇关于是否有可能在某些事件中更改地址栏或浏览器中的URL更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!