Skip to content Skip to sidebar Skip to footer

Back Button On Browser Making No-cached Page Accessible

So I'm testing this ephemeral images functionality in an HTML document (a la Snapchat). My images are visible for X seconds, after which the page reloads and the displayed images

Solution 1:

Don't refresh the page, instead use simple DOM manipulation to remove the image. If you have jQuery loaded, you can easily do it like so:

<script>window.setTimeout(function () {
    $( 'img' ).remove();
}, 5000); // refresh/redirect after 5 seconds.</script>

(You'll want to use a more specific selector if you have more than one image on the page)

To load a new image in this context, you'll need to use an AJAX request, and set a new timer. But this will cause the back button to not bring the image back.

Post a Comment for "Back Button On Browser Making No-cached Page Accessible"