Get previous page phonegap javascript

落花浮王杯 提交于 2019-12-08 20:15:33
caiocpricci2

If you want something built in you can use document.referrer to get the previous URL. But it might not be reliable for your needs. More info here, here and here

Another VERY simple option is to store the current page name in the session storage, read it and then decide what to do next.

//retrieve the previous page
var previouspage = window.sessionStorage.getItem("page"):
// if thee is no previous page you are on the first page
if (previousPage == undefined){
 //do something if you want, this means it's the first page the user is seeing
 }
//get current page address
var currentPage = window.location.href;
//store it
window.sessionStorage.setItem("page",currentPage); 
//check if the previous page is the one you wanted.
if (previousPage == "the_page_you_wanted"){
 // do something.
 }

LocalStorage vs SessionStorage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!