IE/javascript div resizing/incorrect image loading
"Seb Frost" <[email protected]> Fri, 31 Mar 2006 12:26:17 +0100
| Newsgroups | gmane.comp.web.dom.wdf |
|---|---|
| Message-ID | <[email protected]> |
Using Fiddler I've realised that a script I have that merely resizes a div
will cause images to be called multiple times if they're inside that div.
For instance, suppose I have 6 LIs in the div, each with a background image
of a bullet point:
1) without the script, the bullet point correctly only gets requested once.
2) with the script, the bullet point is requested 7 times by the browser (so
once initially, then once for each LI after the resize).
Here is the script:
-------------------------------------------------------
function $(e){return document.getElementById(e);}
function init()
{
var c1=$('left').offsetHeight,
c2=$('content').offsetHeight,
c3=$('right').offsetHeight;
var cmax=Math.max(c1,c2,c3);
var d1=cmax-c1,
d2=cmax-c2,
d3=cmax-c3;
if (d1 > -4) $('left').style.height = $('left').offsetHeight + d1 + 4 +
"px";
if (d2 > 0) $('content').style.height = $('content').offsetHeight + d2 +
"px";
if (d3 > -4) $('right').style.height = $('right').offsetHeight + d3 + 4 +
"px";
}
if (window.attachEvent)
window.attachEvent('onload',init);
else
window.addEventListener('load',init,false);
Doesn't appear to be a problem in firefox, opera etc. Is this an
unavoidable, or an oddity that can be worked around?
Is it also linked to my other problem? (Will send that email in 2 minutes)
Unsubscribe
[email protected]
List info
http://www.quirksmode.org/dom/list.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/wdf-dom/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/