Javascript Resources

A page of Javascript Odds 'n' Ends that may help you

Cache Busting

Browsers are notorious at hanging on tenaciously to cached pages.  Even when you use all manner of fancy headers like "Pragma: no-cache" or "Cache-Control: must-revalidate" you'll often find that you receive a cached page rather than a 'live' one.  Here's something else you can try, which has worked well for me: 

To the URL which requests the page, add a random (and meaningless) variable and value pair.  The value should be different each time, and although it will have no effect on the called page, it helps to fool the browser into thinking it has to return a page from a URL it's never visited before, rather than realising it has it in cache.

A good way to do this in Javascript is to add a random number:

var myurl='http://www.mydomain.com/data.php';
myRand=parseInt(Math.random()*99999999);  // cache buster
window.open(myurl + "?rand=" + myRand,
"mywindow","status=1,toolbar=1");

Now, each time we open the page whose address is stored in myurl, we append a meaningless variable rand with a random value, eg:

www.mydomain.com/data.php?rand=54321

Getting Browser Information using Javascript

 Here is a listing of the Navigator/Browser settings for your browser:

 document.write("Browser appName="+navigator.appName);
 document.write("Browser appCodeName="+navigator.appName);
 document.write("Browser appVersion="+navigator.appVersion);
 document.write("Browser language="+navigator.language);
 document.write("Browser cookieEnabled="+navigator.cookieEnabled);
 document.write("Browser cpuClass="+navigator.cpuClass);
 document.write("Browser onLine="+navigator.onLine);
 document.write("Browser platform="+navigator.platform);
 document.write("Browser No of Plugins="+navigator.plugins.length);

And here is what it says about your browser!

Your feedback on these tutorials is important.  Please don't forget to sign the guestbook ....


Amazon Books: Mouse over for brief details or click to visit

 
Site Map Page loaded in 0.08165 sec
© 2005 The Mouse Whisperer