X
Tap here to go to the mobile version of the site.
Your Firefox is out of date and may contain a security risk! Upgrade Firefox

Support Forum

JavaScript code to change height of HTML div, table or img won't work. How?

Posted

The following JaverScript code won't work with Firefox browser but works OK with Internet Explorer on HTML code for

div, table and img objects.
<script type="text/javascript">

    height = document.documentElement.clientHeight;
    document.getElementById('div1').style.height = Math.round((height / 560) * 500); //Division height
    document.getElementById('Img1').style.height = Math.round((height / 560) * 180); //Image height
    document.getElementById('tbl1').style.height = Math.round((height / 560) * 300); //Table height

</script>

Modified by cor-el

Additional System Details

Sites Affected

http://www.poultonartsociety.co.uk/gallery.htm

Installed Plug-ins

  • Default Plug-in
  • Adobe PDF Plug-In For Firefox and Netscape "9.3.4"
  • 4.0.50826.0
  • Office Live Update v1.5
  • NPWLPG
  • Google Update
  • Wacom Dynamic Link Library

Application

  • User Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3

More Information

Maximise and Minimize should change heights to fill screen. It works OK on Internet Explorer. Other similar pages and sites are affected.

cor-el
  • Top 10 Contributor
  • Moderator
10781 solutions 97024 answers

Helpful Reply

You need to add 'px' to the height:

function resize() {
    height = document.documentElement.clientHeight;
    imgheight = Math.round((height / refheight) * 530);
    document.getElementById('Image1').style.height = imgheight+'px';  //background height
    setTimeout("resize()", resize_delay);
}