html5 / jquery后退按钮 [英] html5/jquery back button
问题描述
是否有一个库或一段代码使一个特定的按钮就像一个正确的浏览器后退按钮,它将带你到之前加载的上一页?
Is there a library or piece of code that makes a specific button act as like a proper browser back button where it will take you to the previous page that was loaded before?
目前我只是指定 href
,我认为是先前加载的页面,但得出的结论是,这不起作用,因为a可以从不同的屏幕访问屏幕。
At the moment I'm just specifying the href
of what I assume was the page that was previously loaded but came to the conclusion that this won't work because a screen could have been accessed from different screens.
是否有这样的例子,或者我是否需要创建自己的逻辑来跟踪页面历史记录?
Is there an example of this or do I need to create my own logic that tracks page history some how?
谢谢
推荐答案
导航回来 - 单个文件模板:
Navigate back - Single-file template:
$('.selector').on('click', function (e) {
e.preventDefault();
var page = $.mobile.activePage.prev('[data-role=page]');
$.mobile.changePage(page, {
transition: 'flip',
reverse: true
});
});
导航回来 - 多文件模板:
Navigate back - Multi-files template:
$('.selector').on('click', function (e) {
e.preventDefault();
var page = document.referrer;
$.mobile.changePage(page, {
transition: 'flip',
reverse: true
});
});
Demo
这篇关于html5 / jquery后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!