How to dynamically expand the javascript height?
Hi,
Is it possible to know the div tag height & expand it dynamically with the help of javascript?
The div contains an image & according to the image the div gets adjusted. I want to get the actual height of the page while loading & adjust it dynamically with the help of javascript. Is this possible? If yes can I get to see an example?
Re: How to dynamically expand the javascript height?
Hey give this a try:
Code:
var DivHeight = document.getElementById(DivID).clientHeight;
I hope this helps.
Re: How to dynamically expand the javascript height?
Try this:
Code:
document.getElementById("divName").style.height = windowHeight - 100+"px";
This is an example:
Code:
<html><body>
<style type="text/css">
#divName {
border:solid 1px #000;
text-align:center;
}
</style>
<script type="text/javascript">
var windowWidth=screen.availWidth/2+"px";
var windowHeight=screen.availHeight/4*3+"px"
function sniffer() {
var el=document.getElementById("divName");
if(screen.width==1280) {
el.style.width=windowWidth;
el.style.height= windowHeight;
el.style.margin="auto";
}
else {
if(screen.width==1024) {
el.style.width=windowWidth;
el.style.height= windowHeight;
el.style.margin="auto";
}
else {
if(screen.width==800) {
el.style.width=windowWidth;
el.style.height= windowHeight;
el.style.margin="auto";
}
}
}
}
onload=sniffer;
//]]>
</script>
</head>
<body>
<div id="divName"></div>
</body></html>
Re: How to dynamically expand the javascript height?
Thanks a lot for the prompt reply
Ill definitely give it a try & let you know soon.
Regards
Recko