Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The push notification is discarded because when refreshing the browser window, the current state (including the entire DOM) is discarded. You need to persist the message either on the server-side or the client-side.</p> <p>If you already use a form of sessions, you could write the messages into your the active <strong>session</strong>. Or if you already store the notifications at some point before submitting them, you could simply delay removing them from that storage (either for a certain amount of time or until the user dismisses them, sending an event back to the server) and re-send all stored notifications on each initial connection.</p> <p>But because you say you want to avoid writing to a db, I assume this is out of the question.</p> <p>The traditional solution to storing state on the client-side is to do so using <strong>cookies</strong>. You can set cookies on the client-side as well by manipulating <code>document.cookie</code>, but that's a bit ugly.</p> <p>The <a href="http://www.html5rocks.com/en/features/storage" rel="nofollow">more modern approach</a> is using <strong>localStorage</strong> (a domain-and-port-specific key-value storage supported by most modern browsers) or its brethren. If you don't want to rely on HTML5 support (e.g. you're dealing with IE6 users), then <a href="https://github.com/bebraw/jswiki/wiki/Storage-libraries" rel="nofollow">there are plenty of solutions</a> that offer a wide range of abstractions around the various equivalents. Note that with IE8 and below the storage size may be very limited, so be careful what kind of data you dump into it.</p> <p>If you are comfortable restricting support of this feature to users of modern web browsers and want to remain within jQuery, <a href="http://plugins.jquery.com/localstorage/" rel="nofollow">there's even a jQuery plugin for that</a>, which provides a wrapper around both <code>localStorage</code> and <code>sessionStorage</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload