On 02/12/2016 02:33 AM, Otis Rothenberger wrote:
> It turns out that there is a JQuery solution to the Safari back/forward 
> browser cache issue:
>
> $(window).bind("pageshow", function(event) {
>      if (event.originalEvent.persisted) {
>          window.location.reload()
>      }
> });
>
> http://stackoverflow.com/questions/8788802/prevent-safari-loading-from-cache-when-back-button-is-clicked
>
> This only brings Safari to FF/Chrome behavior - i.e. page default reload on 
> back button.
>
> I really need to put some time in dealing with the local storage saved state 
> restore issues rather than just saved molfile re-load. It would be nice to be 
> able to restore state with this approach after  back button or return from a 
> subsequent page.
>
I found another workaround at 
"http://stackoverflow.com/questions/12381563/how-to-stop-browser-back-button-using-javascript";.

Instead of fixing the page reload it prevents going back in history. 
Generally you shouldn't do this. But if you are in a Javascript 
application like JSmol I think it would be more annoying for a user to 
loose the work done than not to be able to go back.

It doesn't solve the problem of going into the 'forward' direction. But 
if all links in the page are set to be opened in a new window/tab it 
should at least be difficult to go somewhere else accidentally.

------- HTML/Javascript -------------------------
<script>
   history.pushState(null, document.title, location.href);
   window.addEventListener('popstate', function (event)
   {
     history.pushState(null, document.title, location.href);
   });
</script>
-------------------------------------------------

I have tested it only in Firefox 43.0.4 and Chromium 31.0 on Linux yet. 
But there it works nicely. Javascript variables retain there content and 
JSmol keeps it's current state. And in comparison to other similar 
solutions within the URL above, a manual page reload still works.

Regards,
Rolf


-- 

Rolf Huehne
Postdoc

Leibniz Institute on Aging - Fritz Lipmann Institute (FLI)
Beutenbergstrasse 11
07745 Jena, Germany

Phone:   +49 3641 65 6205
Fax:     +49 3641 65 6210
E-Mail:  rolf.hue...@leibniz-fli.de
Website: http://www.leibniz-fli.de

           Scientific Director: Prof. Dr. K. Lenhard Rudolph
        Head of Administration: Dr. Daniele Barthel
Chairman of Board of Trustees: Burkhard Zinner

VAT No: DE 153 925 464
Register of Associations: No. 230296, Amtsgericht Jena
Tax Number: 162/141/08228


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to