html5 / jquery后退按钮 [英] html5/jquery back button

查看:134
本文介绍了html5 / jquery后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个库或一段代码使一个特定的按钮就像一个正确的浏览器后退按钮,它将带你到之前加载的上一页?

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屋!

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