John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

How to write JS to determine if the previous history equals a certain page?

Hi,

I need to determine what was the previous page in my history and if it matches a certain page in my app then I want to perform some action. What is the way to write this JS part? For example:

---------------------------------------------------------------------

var a = homepage.html

if (history == a) {
Appery('mobilegrid_218').show();
}

else {
Appery('mobilegrid_218').hide();
}

--------------------------------------------------------------------

the part Im not sure about in this example is "if (history == a)"

Please clarify if this is correct and if not what is the correct structure? Thank You.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to write JS to determine if the previous history equals a certain page?

Hello! Could you clarify what do you mean on "previous history" - previous page you navigated from to the current one? or it's a page user visited some time ago (perhaps a few pages ago)?

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

How to write JS to determine if the previous history equals a certain page?

for this example i need to compare the immediate previous page the user came from.

But, it would be nice to be able to have x number of previous pages navigated from as well.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to write JS to determine if the previous history equals a certain page?

You can check previous page name on Page Show event using the following JS:
codevar prevPageName = '';
if(arguments[1]["prevPage"][0]) {
prevPageName = $(arguments[1]["prevPage"][0]).attr("dsid");
}
if (prevPageName == 'homepage') {
Appery('mobilegrid_218').show();
} else {
Appery('mobilegrid_218').hide();
} /code

[quote:]have x number of previous pages navigated from[/quote] it's better to save into localStorage each visited page.

Return to “Issues”