Stefan Hayden

Alt + Ctrl + X

OMG Safari for the PC. I hate Safari. Besides that after seeing Firefox render differently on mac, pc, and linux and IE rendering differently everywhere I can’t imaging safari will be pixel for pixel between the mac and pc. My god another illegitimate bastard browser to check up on.

1 Comment
Gravatar

I know exactly how you feel… I wonder what flavour of JavaScript it has.

Just ponder the following for a sec:

/** getViewportGeometry()
*
* Return geometry {x, y, width, height} of current viewport.
*/
function getViewportGeometry() {
var left = 0;
var top = 0;
var width = 0;
var height = 0;

if (typeof window.pageYOffset != ‘undefined’) {
left = window.pageXOffset;
top = window.pageYOffset;
} else if (typeof document.documentElement.scrollTop != ‘undefined’
&& (document.documentElement.scrollTop > 0 ||
document.documentElement.scrollLeft > 0)) {
left = document.documentElement.scrollLeft;
top = document.documentElement.scrollTop;
} else if (typeof document.body.scrollTop != ‘undefined’) {
left = document.body.scrollLeft;
top = document.body.scrollTop;
}

if (typeof window.innerWidth != ‘undefined’) {
width = window.innerWidth;
height = window.innerHeight;
} else if (typeof document.documentElement != ‘undefined’
&& typeof document.documentElement.clientWidth != ‘undefined’
&& document.documentElement.clientWidth != 0) {
width = document.documentElement.clientWidth;
height = document.documentElement.clientHeight;
} else {
width = document.getElementsByTagName(‘body’)[0].clientWidth,
height = document.getElementsByTagName(‘body’)[0].clientHeight
}

return {
x: left,
y: top,
width: width,
height: height
};
}

Why on earth doing simple things consistently is so damn hard in the browser world! JavaScript is dying for “use strict; use warnings;”…

Feed Icon Comment Feed

Post a Comment