在jQTouch中确定上一页(即引荐来源网址) [英] Detemine the previous page (i.e. referrer) in jQTouch
问题描述
我正在尝试确定上一页(例如引荐来源网址),以便决定是否显示后退"按钮.
I am trying to determine the previous page (e.g. the referrer) in order to decide whether to display the back button.
我试图检查$('.current').data('referrer')
,但并非始终设置该值.实际上,它通常没有设置.似乎也没有设置history.previous
和document.referrer
.
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.
有人可以启发我吗?
推荐答案
我不想走这条路,但我能找到的唯一可行的解决方案是jQTouch保留内部变量(即hist
).浏览记录.因此,我对jqouth.js进行了以下更改(修订146):
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):
在第256行附近,在私有功能"部分之前,插入:
around line 256, just before the private functions section, insert:
function getHistory() { return hist; }
在625行附近,在submitForm: submitForm
之前,插入:
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.
编辑:
自版本14开始,作者就公开了内部历史记录对象. 2010年10月,因此可以直接访问它,即jQT.hist
.
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
.
这篇关于在jQTouch中确定上一页(即引荐来源网址)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!