Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  20] [ 3]  / answers: 1 / hits: 54555  / 14 Years ago, sun, january 16, 2011, 12:00:00

G'day guys,



I'm trying to figure out the best way to check for empty storageSession in HTML5.



I noticed that some browser returns null and some return just empty space if you clear or did not set any values to the sessionStorage.



I've tried the following



if (sessionStorage.getItem('value1') == null && sessionStorage.getItem('value2') == null) {


But it doesn't seem to work.



Anyone got a better way to check if a sessionStorage is empty?



Appreciate your help on this and thank you in advance.


More From » html

 Answers
7

That should work; the problem is that you have null in quotes.



Also, sessionStorage.length will give you the number of values stored.


[#94208] Thursday, January 13, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brodyfrancisi

Total Points: 1
Total Questions: 102
Total Answers: 89

Location: Marshall Islands
Member since Mon, May 31, 2021
3 Years ago
brodyfrancisi questions
;