frankenstrat
asked on
Looping problem in IE7
The following function works perfectly in Firefox but in IE7 it loops. How can I stop the loop in IE7 and achieve the effect I need?
I would suggest that you open the page in Firefox because it will eventually crash IE. You can use the IE tab switch plugin in Firefox to view the page and it will be easier to switch back to Firefox rather than viewing in a standalone IE.
example URL: http://eyecreate.ods.org/eyecreate/
function findWindowDim(){
/*Constructing the function to work with Netscape 6 (innerHeight)
and Netscape 7+, Mozilla 1.0.1+ and IE6+ (clientHeight).*/
//Determining browser type by functionality.
//Start IE5+, NS7 and Mozilla based on build 1.0.1
//var objCenter = document.getElementById('c entercolum n')
var leftHeight = document.getElementById('l eftcolumn' ).offsetHe ight;
var rightHeight = document.getElementById('r ightcolumn ').offsetH eight;
var mastheadHeight = document.getElementById('m asthead'). offsetHeig ht;
var centerHeight = document.getElementById('c entercolum n').offset Height;
var containerHeight = document.getElementById('c ontainer') .offsetHei ght;
var objFooter = document.getElementById('f ooter')
var objLeft = document.getElementById('l eftcolumn' )
var objRight = document.getElementById('r ightcolumn ')
var objCenter = document.getElementById('c entercolum n')
var objContainer = document.getElementById('c ontainer')
if ((centerHeight > leftHeight) && (centerHeight > rightHeight)) {
footerTop = mastheadHeight + centerHeight;
footerTopPx = footerTop+"px"
objFooter.style.top = footerTopPx
colHeight = centerHeight + 3;
Height = colHeight+"px"
objRight.style.height = Height;
CentercolHeight = centerHeight - 15;
CenterCol = CentercolHeight+"px"
objCenter.style.height = CenterCol;
objLeft.style.height = Height;
objRight.style.height = Height;
objContainer.style.height = footerTopPx;
} else if ((rightHeight > leftHeight) && (rightHeight > centerHeight)) {
// If the right column is longer than the centre and left columns
footerTop = mastheadHeight + rightHeight;
footerTopPx = footerTop+"px"
objFooter.style.top = footerTopPx
colHeight = rightHeight;
rHeight = colHeight+"px"
objLeft.style.height = rHeight;
CentercolHeight = rightHeight - 15;
CenterCol = CentercolHeight+"px"
objCenter.style.height = CenterCol;
objContainer.style.height = footerTopPx;
} else if ((leftHeight > centerHeight) && (leftHeight > rightHeight)) {
// If the left column is longer than the centre and right columns
footerTop = mastheadHeight + leftHeight;
footerTopPx = footerTop+"px"
objFooter.style.top = footerTopPx
colHeight = leftHeight;
lHeight = colHeight+"px"
objRight.style.height = lHeight;
CentercolHeight = leftHeight - 15;
CenterCol = CentercolHeight+"px"
objCenter.style.height = CenterCol;
objContainer.style.height = footerTopPx;
} else {
// If left and right columns are shorter than the centre column
footerTop = mastheadHeight + centerHeight + 6;
footerTopPx = footerTop+"px"
objFooter.style.top = footerTopPx
CenterCol = centerHeight+"px"
objLeft.style.height = CenterCol;
objRight.style.height = CenterCol;
objContainer.style.height = footerTopPx;
}
}
I would suggest that you open the page in Firefox because it will eventually crash IE. You can use the IE tab switch plugin in Firefox to view the page and it will be easier to switch back to Firefox rather than viewing in a standalone IE.
example URL: http://eyecreate.ods.org/eyecreate/
function findWindowDim(){
/*Constructing the function to work with Netscape 6 (innerHeight)
and Netscape 7+, Mozilla 1.0.1+ and IE6+ (clientHeight).*/
//Determining browser type by functionality.
//Start IE5+, NS7 and Mozilla based on build 1.0.1
//var objCenter = document.getElementById('c
var leftHeight = document.getElementById('l
var rightHeight = document.getElementById('r
var mastheadHeight = document.getElementById('m
var centerHeight = document.getElementById('c
var containerHeight = document.getElementById('c
var objFooter = document.getElementById('f
var objLeft = document.getElementById('l
var objRight = document.getElementById('r
var objCenter = document.getElementById('c
var objContainer = document.getElementById('c
if ((centerHeight > leftHeight) && (centerHeight > rightHeight)) {
footerTop = mastheadHeight + centerHeight;
footerTopPx = footerTop+"px"
objFooter.style.top = footerTopPx
colHeight = centerHeight + 3;
Height = colHeight+"px"
objRight.style.height = Height;
CentercolHeight = centerHeight - 15;
CenterCol = CentercolHeight+"px"
objCenter.style.height = CenterCol;
objLeft.style.height = Height;
objRight.style.height = Height;
objContainer.style.height = footerTopPx;
} else if ((rightHeight > leftHeight) && (rightHeight > centerHeight)) {
// If the right column is longer than the centre and left columns
footerTop = mastheadHeight + rightHeight;
footerTopPx = footerTop+"px"
objFooter.style.top = footerTopPx
colHeight = rightHeight;
rHeight = colHeight+"px"
objLeft.style.height = rHeight;
CentercolHeight = rightHeight - 15;
CenterCol = CentercolHeight+"px"
objCenter.style.height = CenterCol;
objContainer.style.height = footerTopPx;
} else if ((leftHeight > centerHeight) && (leftHeight > rightHeight)) {
// If the left column is longer than the centre and right columns
footerTop = mastheadHeight + leftHeight;
footerTopPx = footerTop+"px"
objFooter.style.top = footerTopPx
colHeight = leftHeight;
lHeight = colHeight+"px"
objRight.style.height = lHeight;
CentercolHeight = leftHeight - 15;
CenterCol = CentercolHeight+"px"
objCenter.style.height = CenterCol;
objContainer.style.height = footerTopPx;
} else {
// If left and right columns are shorter than the centre column
footerTop = mastheadHeight + centerHeight + 6;
footerTopPx = footerTop+"px"
objFooter.style.top = footerTopPx
CenterCol = centerHeight+"px"
objLeft.style.height = CenterCol;
objRight.style.height = CenterCol;
objContainer.style.height = footerTopPx;
}
}
ASKER
Thanks for the try but that didn't work.
ASKER
Problem has been resolved. The padding in the style sheet was different for each layer which produced erratic results.
*Just out of curiosity*, did you isolate which padding in the CSS caused IE to freeze?
Can you reproduce it with minimal code?
Can you reproduce it with minimal code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
window.onresize = findWindowDim;
Inside findWindowDim, you do something that triggers window.onresize again, so it loops.
A possible solution: put
window.onresize = null
as the fist line of findWindowDim, and
window.onresize = findWindowDim
as the last line.
Again, I maybe wrong in this, I didn't have time to read your code extensively...