Monday, June 24, 2013

Get Web Browser Height and Width by Javascript

Get the Browser height and width using javascript.you can provide dynamic width or height of any element by using javascript.

 See the example for it :

<html>
<head>
<script>
function getload()
{
var all=document.body.offsetWidth;
var final=all-1000;
document.getElementById('test').style.width=final+"px";
}
</script>
</head>
<body onload="getload()">
<div id="test" style="border:1px solid blue;">hello
</div>
</dody>
</html>


here get the document body width it provide the current document width by browser resolution. 



No comments:

Post a Comment

Thanks....