Last Updated: February 25, 2016
·
1.691K
· idered

Bookmarklet: Debug window width & height

A small bookmarklet which helps you view window width and height during resizing page.

Result:

Drag this code to your bookmarks:

javascript: var debug=document.createElement('div');debug.id='#debug-window';debug.style.font='16px/1.5 Arial';debug.style.color='#fff';debug.style.textAlign='right';debug.style.background='#333';debug.style.padding='.5em 1em';debug.style.position='fixed';debug.style.bottom=0;debug.style.right=0;debug.style.borderRadius='3px 0 0 0';(document.getElementsByTagName('body')[0]).appendChild(debug);window.onresize=function(){debug.innerHTML=window.innerWidth+'x'+window.innerHeight+'px';};window.onresize();

Here's the source:

var debug = document.createElement('div');

debug.id = '#debug-window';
debug.style.font = '16px/1.5 Arial';
debug.style.color = '#fff';
debug.style.textAlign = 'right';
debug.style.background = '#333';
debug.style.padding = '.5em 1em';
debug.style.position = 'fixed';
debug.style.bottom = 0;
debug.style.right = 0;
debug.style.borderRadius = '3px 0 0 0';

(document.getElementsByTagName('body')[0]).appendChild(debug);

window.onresize  = function() {
    debug.innerHTML = window.innerWidth + 'x' + window.innerHeight + 'px';
};

window.onresize();

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside