0

I have a function in javascript that is generating an array of canvas elements (screenshots of the current webpage). If the user clicked on a new link, I want to save my current array and somehow send it to the new page where I will call the function again, but with the array already filled by the previous values, through the same javascript file (I want it all to remain client side).

This was for context. So my question is, can I send data to pages sharing the same domain, client side? Is there some way I can store the information maybe, and then access it later, without going server side?

Rawan Moukalled
  • 93
  • 1
  • 1
  • 8

1 Answers1

0

If you want to share these 'canvases' between tabs/websites then you should remember that inside localstorage or cookies you can only store STRINGS. You cannot store canvas as a string (you would get something like "[object HTMLCanvasElement]" which is nonsense in this case, but you can convert them to images and then convert images to strings, which you can then store inside localstorage or cookies.

Azamantes
  • 1,435
  • 10
  • 15
  • Yes, before sending I am going to convert each of them to base64 encoded strings. But I found that cookies and localstorage can only be accessed by one page, so if I created a cookie in example.com/a, then example.com/b would not have access to it, right? – Rawan Moukalled May 25 '16 at 12:45
  • Have you tried sharing information between subdomains via cookies? – Azamantes May 25 '16 at 12:50