tags:

views:

25

answers:

5

Suppose a javascript holds an object on page A (www.example.com/a.html)

Suppose the user clicks on page B (same domain) (www.example.com/a.html)

is it possible for the javascript on page B to access the object from a.html ?

I don't want tricks to transfer the object, like posting to the webserver or adding parameters to the url.

Thanks, E

p.s. Just adding this 'p.s.' following some of the answers: Using a cookie is not an option because the data on page A would be very very very large.

+1  A: 

Not a true solution but html5 localstorage might be an option. (That is if you want to live on the bleeding edge of web technology.)

And the best part: it does not include any post/url tricks as you requested. :-)

Chris
I will check that out. thanks
erik
A: 

Check out the jStorage plugin here: http://www.jstorage.info/ Works on almost all engines that matter: Trident, Gecko, Webkit, etc.

Its a simple way to store objects.

lark
A: 

In general, no -- state is not preserved between requests in a browser. When you navigate between pages, the first page is completely unloaded (DOM, Javascript variables, etc.) and the second page is then loaded.

There are some ways that you can preserve data outside of Javascript without hitting the server though, such as cookies, or HTML5's localstorage as Chris mentioned.

Daniel Vandersluis
A: 

What about saving the serialised object in a Cookie using JSON?

kschaper
+1  A: 

There's no direct way for page B to access the object, because the object will no longer exist once page A is unloaded. As other answers note, you can store the object somewhere, and then page B can get a copy of the original object from page A.

A cookie is another alternative to local storage.

Pointy