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 :)
Written by Luke Hopkins
Related protips
2 Responses
In Chrome you have to use keydown instead of keypress.
over 1 year ago
·
Good point, didn't notice because I develop in Firefox :p will edit now. Thanks for the input :)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Responsive
Authors
Related Tags
#responsive
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#