Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 类Pinterest的ajax加载_Wordpress_Jquery_Browser History_Pinterest - Fatal编程技术网

Wordpress 类Pinterest的ajax加载

Wordpress 类Pinterest的ajax加载,wordpress,jquery,browser-history,pinterest,Wordpress,Jquery,Browser History,Pinterest,我正在使用Wordpress开发一个网站,在该网站上,文章将通过AJAX加载,同时将url更改为文章的实际永久链接。比如pinterest的工作原理。AJAX加载的内容显示在模式框中。我用 将浏览器的url更改为文章的永久链接。现在我的问题是: 当模式框关闭时,我希望在不重新加载页面的情况下转到上一个url e、 我在主页上(http://example.com),然后单击一篇文章,模式框打开,通过AJAX获取文章内容,url变为(http://example.com/post1). 当模式框关

我正在使用Wordpress开发一个网站,在该网站上,文章将通过AJAX加载,同时将url更改为文章的实际永久链接。比如pinterest的工作原理。AJAX加载的内容显示在模式框中。我用

将浏览器的url更改为文章的永久链接。现在我的问题是:

当模式框关闭时,我希望在不重新加载页面的情况下转到上一个url


e、 我在主页上(http://example.com),然后单击一篇文章,模式框打开,通过AJAX获取文章内容,url变为(http://example.com/post1). 当模式框关闭时,我希望url返回到(http://example.com)没有实际的页面重新加载。所以基本上只会恢复到前一个状态。

所以使用相同的方法更改url,就像打开时一样,但在模式窗口的关闭事件时触发它

编辑:若要转到根url,您可以执行以下操作:
window.history.pushState(“”,“/”)

以这种方式尝试(在关闭事件时):window.history.pushState(“”,“,”);因为我想从中转到,但这并不影响url,因为这只意味着没有任何东西可以连接到url。如果我想从中转到,我该如何实现?window.history.pushState(“”,“,”/post1')通常从您要去的地方开始并不重要