drifterz28
1/29/2014 - 6:37 PM

Detect and show window size in upper left of page.

Detect and show window size in upper left of page.

(function () {
    // I know chrome does this but I would like it to stay around.
    // update, chrome does not do this any more.
    var scaler,
        scaleWrapper = ['<div id="scaleShow"',
                        'style="position:fixed;background:#fff;top:0;left:0;padding:5px;opacity:0.6;">',
                        window.innerWidth + 'px x ' + window.innerHeight + 'px - ' + window.devicePixelRatio,
                        '</div>'].join(' ');

    document.body.insertAdjacentHTML('beforeend', scaleWrapper);
    scaler = document.getElementById('scaleShow');
        
    window.addEventListener('resize', function () {
        scaler.textContent = window.innerWidth + 'px x ' + window.innerHeight + 'px';
    });

}());