SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    setting the height of a div not works in ff and ie

    I have 2 div when one is clicked i want set the height of the other div equals the height of body
    the part of code is:
    ...
    <div
    onclick='document.getElementById("immagini").className="semitrasparenza"; document.getElementById("immagini").style.height=document.body.offsetHeight;'
    ></div>
    ...
    why this works in opera
    but in ff release this error:
    "the property that has only getter"?

    How i can to solve the problem?
    Thanks

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to add px to the end of the value.

    Also you are best off sticking this inside a function, it's easier to deal with.

    Code:
    <script>
    
    function changeImageClass(which)
    {
    var el = document.getElementById(which);
    el.className = 'semitrasparenza';
    el.style.height = document.offsetHeight + 'px';
    }
    </script>
    
    <div onclick="changeImageClass('immagini');"></div>



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •