delphi programming forums mysql charset mget recursive synonimos
free ventrilo servers hosting cs javascript delay python find in list
Back Forum New
abstract:

var ab = document.getElementById('left').offsetTop + document.getElementById('left').offsetHeight;
var ac = document.getElementById('right').offsetTop + document.getElementById('right').offsetHeight;
var total = gh
if(ab > total){ total = ab; }
if(ac > total){ total = ac; }
footer.style.top = total;
In internet explorer the script works fine and in firefox it does mpt work, the footer div stays at position -300


Hello,
I have a website made of 4 div's that are set with have these settings:
Code:
  1. #all { color: white; font-size: 10px; background-color: #282828; position: relative; width: 532px; min-height: 740px; margin: 7px auto 30px; padding: 348px 297px 10px 174px; }
  2. #left { position: absolute; top: 348px; left: 0; }
  3. #footer { position: absolute; top: [b]-300px[/b]; left: 0;  }
  4. #right { position: absolute; top: 609px; right: 0; width: 131px; }
Copy Code
Because the all, left and rights div's variate in size I made a javascript that moves the footer div to the appropiate place at the bottom of the page.
Code:
  1. var gh = document.getElementById('all').offsetHeight;
  2. var ab = document.getElementById('left').offsetTop + document.getElementById('left').offsetHeight;
  3. var ac = document.getElementById('right').offsetTop + document.getElementById('right').offsetHeight;
  4. var total = gh
  5. if(ab > total){ total = ab; }
  6. if(ac > total){ total = ac; }
  7. footer.style.top = total;
Copy Code
In internet explorer the script works fine and in firefox it does mpt work, the footer div stays at position -300

TOP

Well maybe IE is an exception, but I thought offsetTop, etc were supposed to be readOnly.
use document.getElementById("").style.left/top and set position = absolute/relative.
And do not declare the footer's left style in the style shee. Set it with javascript window.onload or inline style.

TOP

also when I add this line to the script:
Code:
  1. alert(total);
Copy Code
I get this in IE: 2012
And in FF i get this: 1968
On the same page.
And somehow this line doesn't work in FF:
Code:
  1. document.getElementById('footer').style.top = total;
Copy Code
I got it fixed now, I used position:relative instead of position:absolute to position the footer div on the right place.
I still think it is strange that the javascript did not work in firefox.



var ab = document.getElementById('left').offsetTop + document.getElementById('left').offsetHeight;
var ac = document.getElementById('right').offsetTop + document.getElementById('right').offsetHeight;
var total = gh
if(ab > total){ total = ab; }
if(ac > total){ total = ac; }
footer.style.top = total;
In internet explorer the script works fine and in firefox it does mpt work, the footer div stays at position -300

TOP

Back Forum