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

nagivate to a page if a local storage value is "?"

Hi, I wrote this JS to nagivate to a page if a local storage value is equal to '1'... Is there something wrong with the way i wrote it bc its not working?:

// if local storage variable 'test_cart1' value is equal to '1' then nagivate to 'Main' page
if(localStorage('test_cart1') == 1 )
Appery.navigateTo('Main', {
transition: 'flip',
reverse: false
});

I also did verify the value of '1' does exist in that local storage variable 'test_cart1'

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

nagivate to a page if a local storage value is "?"

I ran firebug and it gave me an error: TypeError: localStorage is not a function

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

nagivate to a page if a local storage value is "?"

The local storage API is:

locaStorage.getItem(key)
localStorage.setItem(key, value);

https://developer.mozilla.org/en-US/d...

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

nagivate to a page if a local storage value is "?"

ok, but how would it look like in this case bc Im still not sure?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

nagivate to a page if a local storage value is "?"

Hi John,

Run the following JavaScript:
precode>// if local storage variable 'test_cart1' value is equal to '1' then nagivate to 'Main' page
if (localStorage.getItem('test_cart1') == 1) {
Appery.navigateTo('Main', {
transition: 'flip',
reverse: false
});
}/code/pre

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

nagivate to a page if a local storage value is "?"

that does work. Ok I understand how that API works now. Thank you much guys.

Return to “Issues”