/ Published in: JavaScript
Also selects different sized header images for better image quality.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var iDevice = ''; if (/iPhone/.test(navigator.userAgent) || /iPod/.test(navigator.userAgent)) { iDevice = ' iphone'; } else if (/iPad/.test(navigator.userAgent)) { iDevice = ' ipad'; } var myWidth = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; } document.write("<DIV ID=\"page"); if (myWidth>1024) { if (myWidth>1280) { document.write("-over-1280"); } document.write("\" CLASS=\"highres"); } else { document.write("\" CLASS=\"lowres"); } document.write(iDevice); document.write("\"><DIV ID=\"header\"><A HREF=\"/\"><IMG ID=\"masthead\" SRC=\"/"); if (myWidth>1152) { document.write("1280"); } else if (myWidth>1024) { document.write("1152"); } else if (myWidth>800) { document.write("1024"); } else if (myWidth>640) { document.write("800"); } else { document.write("640"); } document.write(".png\" ALT=\"confoozled.com\"></A></DIV>");