确定jQTouch中的上一页(即referrer)
我试图确定上一页(例如引用者),以便决定是否显示后退按钮。
我尝试检查 $('.current').data('referrer')
,但并不总是已设置。事实上,它经常没有被设置。 history.previous
和 document.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我一直在使用推荐人解决同样的问题,但我没有得到这一点。
我想出了以下解决方案,它不会强迫我修改 jqtouch.js
$('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
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.
我不想走这条路,但我能找到的唯一可行的解决方案是 jQTouch 保留浏览历史记录的内部变量(即
hist
)。因此,我对 jqouth.js(修订版 146)进行了以下更改:在第 256 行左右,在私有函数部分之前,插入:
在第 625 行左右,在
submitForm:submitForm
之前,插入:然后我可以通过以下方式查看浏览历史记录:
一个警告是,应注意不要意外操作历史对象。
编辑:
作者自 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:
around line 625, just before
submitForm: submitForm
, insert:Then I can look at the browsing history with something like:
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
.嗯...我无法发表评论,所以这是关于 William 修改 jqtouch.js 的答案。
我想我会更容易简单地说:
哪里
放置在
。然后就不需要添加该功能了。请记住,您正在访问历史记录本身而不是函数,因此不需要圆括号。
话又说回来,这实际上只适用于旧版本的 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:
Where
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.