Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7508127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:37:31+00:00 2026-05-29T22:37:31+00:00

I am trying to set the div to a certain height inside an empty

  • 0

I am trying to set the div to a certain height inside an empty table cell to set the cell to 100% height. (The whole page consists of just the table with no padding.)

Here is some relevant code:

<table border="0" width="100%">
 <tr>
  <td class="boxmiddleleft"></td>
  <td class="boxmiddlecenter"><script language="javascript" src="includes/clock.js">/*clock*/</script></td>
 </tr>
 <tr>
  <td class="boxbottomleft"><script language="javascript" src="includes/windowsize.js"></script><div id="divbottomresize"></div></td>
  <td class="boxbottomcenter"><button type="button" onclick="resizeheight();">Changed the window height? Reset by pressing this button.</button></td>
 </tr>
</table>

(With the div im trying to change height called ‘#divbottomresize’)

And the JavaScript I am using for this:

var element = "divbottomresize";
function resizeheight(element) {
 var height = 0;
 var body = window.document.body;
 if (window.innerHeight) {
  height = window.innerHeight;
 } else if (body.parentElement.clientHeight) {
  height = body.parentElement.clientHeight;
 } else if (body && body.clientHeight) {
  height = body.clientHeight;
 }
 element.style.height =   ((height - element.offsetTop) + "px");
}

If you have any idea what I am doing wrong please could you tell me. Alternatively if you find other code that does what I want feel free to paste or link me. (I do not want to use jQuery if possible.)

When I run the code in Chrome and go to ‘Inspect Element’ I get the error:

windowsize.js:12Uncaught TypeError: Cannot read property ‘style’ of undefined on the line element.style.height = ((height – element.offsetTop) + “px”);

EDIT: I have changed var element = "divbottomresize"; to var element = document.getElementById("divbottomresize"); as someone helpfully suggested. This still does not work and I get the same error and no height change.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:37:32+00:00Added an answer on May 29, 2026 at 10:37 pm

    The resize function requires the element parameter, so we need to update the HTML:

     <td class="boxbottomcenter"><button type="button" onclick="resizeheight('divbottomresize');">Changed the window height? Reset by pressing this button.</button></td>
    

    Now, we need to change the Javascript, to use the STRING value passed by the function and then retrieve the tag with that ID for further processing:

    function resizeheight(id_element) {
     var div = document.getElementById(id_element);
    
     var height = 0;
     var body = window.document.body;
     if (window.innerHeight) {
      height = window.innerHeight;
     } else if (body.parentElement.clientHeight) {
      height = body.parentElement.clientHeight;
     } else if (body && body.clientHeight) {
      height = body.clientHeight;
     }
     div.style.height =   ((height - div.offsetTop) + "px");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set a <div> to a certain percentage height in CSS,
I'm trying to follow CSS How to set div height 100% minus nPx but
I'm having hard time trying to set certain cell's value in table. Here is
Im trying to set an automatic height a div that contains 2 child elements,
I've been trying to get image-loading dynamically- size dynamically to set wrapper div height
Height of a div I'm trying to set the size of a div according
I am trying to set the width and height of a div exactly equal
I am trying to highlight a certain set of elements on a page by
I'm trying to set a div centered inside another div. This is the html
I'm trying to set the style name of the div of the split between

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.