开发者

IE6 problem with dynamically adjusting the height of a div

All,

Here's what I'm trying to accomplish.

I have a Flash SWF that's embedded in a DIV. Depending on the user's interactions with that SWF, I'd like to dynamically adjust the height of the SWF.

The SWF itself is 1200 pixels tall. By default, the DIV is 690 pixels tall, so the lower part of the SWF is clipped (which is the behavior I want). Then, the DIV will shrink or grow, revealing or clipping more of the SWF.

Here's what my HTML looks like:

<body>
    <div id="flash_wrapper">
        <div id="flash_content">
            This div will be replaced by an object via SWFObject
        </div>
    </div>
</body>

Here's my CSS:

body, html {
    margin: 0;
    padding: 0;
    background:#ffffff;
}
#flash_wrapper {
    width:1000px;
    height:690px;
    margin:0;
}
#flash_content {
    display: block;
    width: 100%;
    height: 100%;
}

Last, I have a JavaScript function that looks like this:

function updateFlashDivHeight(h) {
    document.getElementById("flash_wrapper").style.height = h;
}

The SWF calls that JavaScript function and passes it the height parameter like "900px" and voilá! - the DIV resizes perfectly. So far, this works great in all the browsers I've tested (IE8, Firefox, Chr开发者_如何学Pythonome, Safari), EXCEPT IE6.

I'm a total novice when it comes to this (CSS especially), so I'm probably making a very simple mistake(s).

Many thanks in advance!


Put an alert statement inside the updateFlashDivHeight routine. That way you know if this routine is behaving erraticaly - but is still called, or if your call to this routine is wrong in someway. IE6 has a lot of bugs, so it could be both.

At least that way you know where to look for the culprit.

Sorry if this answer is soo obvious. As a programmer staring at a problem for a long time, you sometimes overlook the obvious. I know I do :)


This is a shot in the dark but are you using LocalConnection in your SWF to communicate with your Javascript function? If so did you double check that the page you're testing is only open in one browser at a time? LocalConnection won't work properly if the page is open in multiple browsers (or two windows in the same browser).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜