var Viewport = new Object(); Viewport.send = function() { // Path with current time to prevent cacheing var path = 'http://www.eoghanmccabe.com/fold/r.php?i=7&t='+(new Date()).getTime(); // Get viewport height // From A List Apart: Exploring Footers (http://alistapart.com/articles/footers) var width = -1; var height = -1; if (typeof window.innerWidth != "undefined") { width = window.innerWidth; height = window.innerHeight; } else if (document.documentElement && typeof document.documentElement.offsetWidth != "undefined" && document.documentElement.offsetWidth != 0) { width = document.documentElement.offsetWidth; height = document.documentElement.offsetHeight; } else if (document.body && typeof document.body.offsetWidth != "undefined") { width = document.body.offsetWidth; height = document.body.offsetHeight; } // Add height and width to path path += '&w='+width+'&h='+height; // Add script element to header (which passes height in params) var script=document.createElement("script"); script.src=path; script.type="text/javascript"; script=Viewport.getHead().appendChild(script); }; Viewport.getHead=function(){ var lowerHead=document.getElementsByTagName("head"); if(lowerHead.length==0){ var upperHead=document.createElement("head"); document.appendChild(upperHead); return upperHead; }else{ return lowerHead[0]; } }; Viewport.send();