Last Updated: February 25, 2016
·
1.741K
· lukeahopkins

Useful Javascript function for Responsive Web Design

UPDATE - This is now redundant as Firefox and Chrome have built in functionality to tell you window width etc.

I spend ages when doing RWD re-sizing the browser and finding parts that need tweaking with media queries, but I never had a solid way of working out what the current width was (using Firebug Inspector took ages!)..

So I created this (obviously this requires jQuery):

$(document).keydown(function(e) {
if(e.keyCode == 45)
{
alert(window.innerWidth);

}
});

Press Insert whenever you need the innerWidth :)

2 Responses
Add your response

Good point, didn't notice because I develop in Firefox :p will edit now. Thanks for the input :)

over 1 year ago ·