Detecting and logging browser dimensions

[javascript]
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

<body>

<div id="log"></div>

<script>

$(document).ready(function() {

var winWidth = $(window).width();
var winHeight = $(window).height();
$(‘#log’).append(‘<div><h1>’ + winWidth + ‘x’ + winHeight + ‘@’ + window.orientation + ‘</h1></div>’);

$(window).resize(function() {

var winWidth = $(window).width();
var winHeight = $(window).height();
$(‘#log’).append(‘<div><h1>’ + winWidth + ‘x’ + winHeight + ‘@’ + window.orientation + ‘</h1></div>’);

});

});

</script>

</body>
</html>
[/javascript]

Leave a Reply