How to Reload a Page Only Once Using Javascript
This code snippet allows reloading a page only once. It will be helpful to prevent some data being cached.
<script language="JavaScript" type="text/javascript"> var reload = false; var loc=""+document.location; loc = loc.indexOf("?reload=")!=-1?loc.substring(loc.indexOf("?reload=")+10,loc.length):""; loc = loc.indexOf("&")!=-1?loc.substring(0,loc.indexOf("&")):loc; reload = loc!=""?(loc=="true"):reload; function reloadPage() { if (!reload) window.location.replace(window.location+"?reload=true"); } //You can call this via the body tag if desired reloadPage(); </script>
Another must read
- Refresh DIV Content Without Reloading Page using jQuery
- AngularJS Interacting with Java Servlet using JSON