Javascript jQuery Mobile pageremove事件中保留的页面的Url/文件名
我试图在jQueryMobile 1.3.2PageRemove事件中获取旧页面(留下的页面)的url/文件名 这适用于Chrome和Firefox:Javascript jQuery Mobile pageremove事件中保留的页面的Url/文件名,javascript,jquery-mobile,Javascript,Jquery Mobile,我试图在jQueryMobile 1.3.2PageRemove事件中获取旧页面(留下的页面)的url/文件名 这适用于Chrome和Firefox: $(document).on("pageremove", function(e){ console.log( $.mobile.path.parseUrl(e.target.dataset.url).filename); }); 但不是在Internet Explorer中 如何以跨浏览器兼容的方式执行此操作 更新 我可以通过在page
$(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上访问它
不过,直接获取它会很好。似乎不可能以跨浏览器兼容的方式在pageremove事件中看到页面的文件名。ie你看不到哪个页面(可能)被删除 但我之前在问题中添加的变通方法对我来说效果很好:
$(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事件之后,因此“on pageremove”中的最后一个页面仍然包含页面显示时的值