views:

76

answers:

1

I wrote some bookmarklets to automate some tasks on a webpage. I'd like to be able to store a value somehow, so that when I run a bookmarklet the second time, it will see that it exists, and try to use it.

I'd like to be able to do that using pure javascript. Kind of like greasemonkey's storage.

+2  A: 

If you don't need to save the value between domains you can use JavaScript cookies, by using document.cookie.
The w3 have a simple example: http://www.w3schools.com/JS/js_cookies.asp,
and here's another example from Microsoft: http://msdn.microsoft.com/en-us/library/ms533693%28VS.85%29.aspx

Kobi
can you provide a snippet?
Geo
one more question:will the cookie be seen across all the tabs that have the page open?
Geo
From a quick test it looks like it does (on Firefox), though different browsers may behave, well, differently.
Kobi
Thanks for all the information.
Geo