页面的URL /文件名保留在jQuery Mobile pageremove事件中(Url/filename of page being left in jQuery Mobile pageremov

编程入门 行业动态 更新时间:2024-10-13 06:14:44
页面的URL /文件名保留在jQuery Mobile pageremove事件中(Url/filename of page being left in jQuery Mobile pageremove event)

我试图在jQuery Mobile 1.3.2 pageremove事件上获取旧页面的url / filename(左边的那个)。

这适用于Chrome和Firefox:

$(document).on("pageremove", function(e){ console.log( $.mobile.path.parseUrl(e.target.dataset.url).filename); });

但不是在Internet Explorer中。

如何以跨浏览器兼容的方式执行此操作?

更新

我可以通过在pageshow事件上设置变量来间接地做到这一点,

$(document).on("pageshow", function(e){ last_page = $.mobile.path.parseUrl(e.currentTarget.URL).filename; });

然后访问pageremove上的那个。

不过直接得到它会很好。

I am trying to get the url / filename of the old page (the one being left) on a jQuery Mobile 1.3.2 pageremove event.

This works in Chrome and Firefox:

$(document).on("pageremove", function(e){ console.log( $.mobile.path.parseUrl(e.target.dataset.url).filename); });

But not in Internet Explorer.

How can I do this in a cross-browser compatible way?

Update

I can do this indirectly by setting a variable on a pageshow event,

$(document).on("pageshow", function(e){ last_page = $.mobile.path.parseUrl(e.currentTarget.URL).filename; });

and then accessing that on pageremove.

It would be nice to get it directly though.

最满意答案

似乎无法以跨浏览器兼容的方式查看页面的文件名保留在pageremove事件上。 即你无法看到哪个页面(可能)被删除。

但我之前添加到问题本身的解决方法对我来说很好:

$(document).on("pageshow", function(e){ last_page = $.mobile.path.parseUrl(e.currentTarget.URL).filename; }); $(document).on("pageremove", function(e){ console.log(last_page); });

这是因为pageshow事件发生在pageremove事件之后,因此“onPageremove”中的last_page仍然包含显示页面时的值。

It appears not to be possible to see the filename of the page being left on a pageremove event in a cross-browser compatible way. ie you can't see which page is (potentially) being removed.

But the workaround I added earlier to the question itself has worked fine for me:

$(document).on("pageshow", function(e){ last_page = $.mobile.path.parseUrl(e.currentTarget.URL).filename; }); $(document).on("pageremove", function(e){ console.log(last_page); });

This works because the pageshow event happens after the pageremove event, and so last_page within the "on pageremove" still contains the value from when the page was displayed.

更多推荐

本文发布于:2023-08-05 21:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437959.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件名   页面   事件中   Mobile   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!