Skip to main content

Hi there,

 

I’m trying to use a conditional statement that checks for 

  • navigator.useragent
  • sessionStorage.get(‘some item’)
  • localStorage.get(‘some item’)

E.g. {% if localStorage.get('some-item') != undefined  %}

<div>Some div</div>

{% else %}

<div>Some other div</div>

{% endif %}  

 

When I preview the page, this doesn’t seem to do what I intend. E.g. if there is no localStorage with that key, it still shows “Some div”

Hi ​@FaredoonCR,

Firstly apologize for the delay. I understand that you want to get in touch with the developer community members, Our team is waiting for your comments so please feel free to post. the query on https://community.freshworks.dev/ where our dev community would be able to assist you with solution to your queries. 

Thank you !!


Hi there,

 

I’m trying to use a conditional statement that checks for 

  • navigator.useragent
  • sessionStorage.get(‘some item’)
  • localStorage.get(‘some item’)

E.g. {% if localStorage.get('some-item') != undefined  %}

<div>Some div</div>

{% else %}

<div>Some other div</div>

{% endif %}  

 

When I preview the page, this doesn’t seem to do what I intend. E.g. if there is no localStorage with that key, it still shows “Some div”

{% if localStorage.get('some-item') %}
True, there are data 
{% else %}
false there are no data 
{% endif %}