0

I currently need to store different information while going through different steps / pages of my website.Currently I use sessionStorag - here an example

sessionStorage.setItem("src", "" + $('#newImage').attr('src'));

The example is an image which should be up to 10 MB. sessionStorage is working fine until the limit exceeds...

Can you suggest an alternative? I would like to not send the data to a database and reload it everytime.

Frnak
  • 6,601
  • 5
  • 34
  • 67
  • Tried `window.URL.createObjectURL()` ? https://developer.mozilla.org/en-US/docs/Web/API/URL.createObjectURL – guest271314 Feb 15 '15 at 21:26
  • thx for the link - however i would like to have something more stable - i just thought there would be an easy answer to that. I might need to upload the file to my database – Frnak Feb 15 '15 at 22:22
  • See also http://stackoverflow.com/questions/27213778/how-can-i-reliably-preload-and-cache-my-ajax-loading-image-across-my-site – guest271314 Feb 15 '15 at 23:25

1 Answers1

0

I dont really know what you are trying to do but if you want to you can try this as an example.

First Page.html:

localStorage.setItem("keypressed", "");
localStorage.setItem("keypressed", "<h3>First Page</h3>Your Answer: " + answer + "<br /> Correct Answer: R<hr>");
window.location.href="Second Page.html";
return true;

Second page.html:

var res = localStorage.getItem("keypressed");
res+= "<h3>Second Page</h3>Your Answer: " + answer + "<br /> Correct Answer: B<hr>";
localStorage.setItem("keypressed", res);
window.location.href="Third Page.html";
return true;

And with the rest of the pages just write the same code as you did with the second page.

And if you're going to send the information or something to another page just write this code into the result page or something.

Result page.html

var result = localStorage.getItem("keypressed");
document.getElementById("result").innerHTML = result;

And then create a div in the result page, like this:

<div id="result"></div>

This was probably not what you expected but this is how you can send data and reciew it, I hope it works out for you !!

Nikki
  • 301
  • 1
  • 2
  • 18
  • Thanks, but the problem is not sending / receiving the data, but the amount of data. Trying to store an image as base64 String... – Frnak Feb 15 '15 at 18:59
  • Ok but if you're trying to send the data to localstorage like in the first page and then in you do desamme it will just add the data. or something just try use local storage... – Nikki Feb 15 '15 at 19:11
  • tried it - but you are not able to use more than 5 MB – Frnak Feb 15 '15 at 20:06
  • Take a look at this link: http://stackoverflow.com/questions/17255786/localstorage-store-large-size-data – Nikki Feb 15 '15 at 20:45
  • Thx for the Link - i think i ll upload it as blob – Frnak Feb 15 '15 at 21:18