Pages Navigation Menu

Coding is much easier than you think

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) 
//You can call this via the body tag if desired

Another must read


About Mohaideen Jamil

Am currently working as a Struts 2 Developer in a reputed IT Organisations. I can help you with teaching Core java and Struts 2. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.