Reputation: 14510
I am trying to redirect users of value of a localstorage key but it doesn't seem to work.
Now this works: window.location = "http://google.com"
but this doesnt: window.location = localStorage.getItem('key1')
The value of the key1 is http://google.com ...
Does it not work because localstorage doesn't take ://
as a string or something like it?
Thanks alot
Upvotes: 2
Views: 1905
Reputation: 7082
This worked fine for me in firefox:
localStorage.setItem("key1", "http://google.com");
window.location = localStorage.getItem('key1');
Most likely you have a mistake somewhere when you store.
Try doing
alert(localStorage.getItem('key1'));
to see what you actually store.
Upvotes: 1