function viewport()
{

var xViewPort,yViewPort;
if (self.innerHeight) // all except Explorer
{
xViewPort = self.innerWidth;
yViewPort = self.innerHeight;
}

else if (document.documentElement && document.documentElement.clientHeight)
// Explorer 6 Strict Mode
{
xViewPort = document.documentElement.clientWidth;
yViewPort = document.documentElement.clientHeight;
}

else if (document.body) // other Explorers
{
xViewPort = document.body.clientWidth;
yViewPort = document.body.clientHeight;

}


alert(xViewPort+'x'+yViewPort);
}

Inspiração