PDA

View Full Version : resize div in IE


leptogenesis
04-19-2006, 10:49 PM
I am still a JavaScript amateur, so hopefully this will be a fairly simple fix. I wrote this script, to be placed in the header of an HTML document. It's supposed to increase the height of the div with id "divone" by 4 pixels if the browser showing the page is Internet Explorer:


<script type="text/javascript">
function fitDiv()
{
var browser=navigator.appName
if(browser=="Microsoft Internet Explorer")
{document.getElementById("divone").style.height = document.getElementById("divone").style.height + 4 + "px"}
}
window.onload=fitDiv;
</script>


Like it's supposed to, it does nothing in other browsers; doesn't even generate an error. But in Internet Explorer, it says there's an invalid argument on the first d in the first document.getElementById("Iframes").style.height. Hence, it ignores the script. Any suggestions?

_Aerospace_Eng_
04-19-2006, 11:10 PM
What is the HTML you are using? And why are you using javascript resize a div for just IE? You can use IE only CSS fules you know.

leptogenesis
04-19-2006, 11:28 PM
What is the HTML you are using?
Remember that site you had me upload to freewebs? it's still that site, except now I'm trying to take into account that the number of iframes changes based on factors determined on the server-side. That means that the height of the div containing the div needs to change. I can figure out what the height of the divs will be on the server side...except, for some reason, a 171-px div with a 2-px border only on the bottom displays 175 pixels high in Internet Explorer, even though it displays 173 pixels high in all other browsers I've tested. If you need me to, I'll upload a more complicated example to freewebs.

And why are you using javascript resize a div for just IE? You can use IE only CSS fules you know.
The reason is that I didn't know that you could write CSS to apply to only one browser. If you could kindly point me to a reference, I would appreciate very much.

_Aerospace_Eng_
04-19-2006, 11:50 PM
Umm if you remove the height of the div the iframes will stack under each other expanding the height of the div. Border does count for overall height and width. 171+ 4px = 175. For IE only CSS rules check out conditional comments (http://www.quirksmode.org/css/condcom.html). You need to start thinking outside of the box. You are making things to hard on yourself.

leptogenesis
04-20-2006, 12:41 AM
I've already tried removing the div height - the page still displays incorrectly in Internet Explorer - IE thinks the div is about 10px tall and displays it about halfway down the page. And I know that border does count for overall height and width. However, it only counts once when you have it set to have a border on the bottom and not on the top.

I did, however, get the conditional comments to work. Thanks for that tip.

I've been playing around with this page for days now to get around the way that Internet Explorer displays its iframes. I only ask here as a last resort, because I know you guys are busy. I probably did make it hard on myself by wanting to make the page a dynamic width. However, I really don't think I have been particularly narrow-minded in my coding of this site.

_Aerospace_Eng_
04-20-2006, 12:46 AM
Can you post an example of where you see IE think its 10px tall and displays halfway down the page?