JS: Window.location el valor de una clave de almacenamiento local

I am trying to redirect users of value of a localstorage key but it doesn't seem to work.

Ahora esto funciona: window.location = "http://google.com"

pero esto no lo hace: 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?

Muchas gracias

preguntado el 08 de noviembre de 11 a las 17:11

1 Respuestas

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.

Trata de hacerlo

alert(localStorage.getItem('key1'));

to see what you actually store.

respondido 08 nov., 11:22

What browser were you using and what version? In firefox 7.0.1 I see google.com . - Roman Goyenko

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.