确定jQTouch中的上一页(即referrer)

发布于 2024-09-14 19:16:27 字数 209 浏览 3 评论 0原文

我试图确定上一页(例如引用者),以便决定是否显示后退按钮。

我尝试检查 $('.current').data('referrer'),但并不总是已设置。事实上,它经常没有被设置。 history.previousdocument.referrer 似乎也没有设置。

有人可以告诉我这个吗?

I am trying to determine the previous page (e.g. the referrer) in order to decide whether to display the back button.

I tried to check for $('.current').data('referrer'), but it is not always set. In fact, it is often not set. history.previous and document.referrer do not seem to be set, either.

Could someone please enlighten me on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

写下不归期 2024-09-21 19:16:27

我一直在使用推荐人解决同样的问题,但我没有得到这一点。
我想出了以下解决方案,它不会强迫我修改 jqtouch.js

$('body>div').bind('pageAnimationStart', function(e, data) {
  if(data.direction === 'out') {
    alert('referrer is : ' + e.currentTarget.id);
  }
});

$('body>div') 选择器应该选择作为 body 的直接子级的所有 div,这在 jqtouch 中是所有页面定义。
我在currentTargetId中的pageAnimationStart返回的事件中找到了原始页面的名称。

如果有人告诉我是否可以对选择器进行更多限制,以及是否还有一种获取当前页面的方法,我将不胜感激。

I have been struggling on the same problem using referrer, but I did not get that.
I came up with the following solution that does not force me to modify the jqtouch.js

$('body>div').bind('pageAnimationStart', function(e, data) {
  if(data.direction === 'out') {
    alert('referrer is : ' + e.currentTarget.id);
  }
});

the $('body>div') selector should select all the div that are direct child of the body, which in jqtouch are all the pages definitions.
I found the name of the origin page in the event returned by pageAnimationStart in currentTargetId.

Would appreciate if somebody would tell me if I can be even more restrictive with the selector and if there is also a way of getting the current page.

厌倦 2024-09-21 19:16:27

我不想走这条路,但我能找到的唯一可行的解​​决方案是 jQTouch 保留浏览历史记录的内部变量(即 hist)。因此,我对 jqouth.js(修订版 146)进行了以下更改:

在第 256 行左右,在私有函数部分之前,插入:

function getHistory() { return hist; }

在第 625 行左右,在 submitForm:submitForm 之前,插入:

getHistory: getHistory,

然后我可以通过以下方式查看浏览历史记录:

var previousPageID = jQT.getHistory()[1].id;

一个警告是,应注意不要意外操作历史对象。

编辑

作者自 2010年10月14日版本,可以直接访问,即jQT.hist

I didn't want to go down this path, but the only viable solution I can find is the internal variable (i.e. hist) that jQTouch keeps the browsing history. So, I made the following changes to jqouth.js (revision 146):

around line 256, just before the private functions section, insert:

function getHistory() { return hist; }

around line 625, just before submitForm: submitForm, insert:

getHistory: getHistory,

Then I can look at the browsing history with something like:

var previousPageID = jQT.getHistory()[1].id;

One caveat is, care should be taken not to accidentally maniplulate the history object.

EDIT:

The author has exposed the internal history object since the version on 14 October 2010, so it can be directly accessed, i.e. jQT.hist.

慢慢从新开始 2024-09-21 19:16:27

嗯...我无法发表评论,所以这是关于 William 修改 jqtouch.js 的答案。

我想我会更容易简单地说:

hist: hist,

哪里

getHistory: getHistory,

放置在

。然后就不需要添加该功能了。请记住,您正在访问历史记录本身而不是函数,因此不需要圆括号。

话又说回来,这实际上只适用于旧版本的 jqtouch。

Hmm...I can't comment, so this is with respect to William's answer of modifying the jqtouch.js.

I think I'll be easier to simply put:

hist: hist,

Where

getHistory: getHistory,

is to be placed.

And then there's no need to add the function. Just remember that you're accessing the history itself and not a function, so no need for the rounded brackets.

Then again, this really only applies to older versions of jqtouch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文