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

  • Home
  • SEARCH
  • 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 8522817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:14:02+00:00 2026-06-11T07:14:02+00:00

Back story: I have an SVG canvas with some polylines on it. I also

  • 0

Back story: I have an SVG canvas with some polylines on it. I also have some HTML <span> and <textarea> elements that need to be positioned precisely in relation to those polylines.

I started by putting the HTML elements in the SVG in <foreignElement> tags, but I had a problem there because IE doesn’t see them at all and Firefox doesn’t see the <textarea>s. So I took them out of the SVG and now every browser sees them.

So far so good. Now the only way I know to make sure they position correctly with the polylines is to give both the HTML elements and the SVG canvas absolute positions with CSS.

Here’s my problem. Above all these elements is a header div. I want the whole SVG business to sit at a reasonable distance below the header. Say 15px. But since the SVG is absolutely positioned, I need to know the height of that header div to get the SVG and related HTML elements into the right place.

I’ve tried jQuery’s .height() method and some related methods. The problem with all of them is that Firefox and Chrome give two different results. I know this doesn’t reflect a real pixel height difference between the two, because I can see visually that the header is slightly taller in FF, yet FF gives a smaller height reading.

How can I get a browser-consistent height reading for my header div? Or at least one that I can use to absolutely position other elements at the same distance below it in every browser.

  • 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-06-11T07:14:04+00:00Added an answer on June 11, 2026 at 7:14 am

    You could try with this function

    function getHeight() {
        return Math.min(
                Math.min(document.body.scrollHeight, document.documentElement.scrollHeight),
                Math.min(document.body.offsetHeight, document.documentElement.offsetHeight),
                Math.min(document.body.clientHeight, document.documentElement.clientHeight)
            );
    
    }
    

    or simply with document.documentElement.clientHeight, which usually does the trick for me in all the browsers I use for testing (Chrome, Firefox, Safari and Opera)

    [edit] The function above returns the width and height of the body, in order to use it for any div, use this one

    function getHeight(div) {
            return Math.min(div.scrollHeight, div.offsetHeight, div.clientHeight);  
        }
    

    You can use it like this

    var myDiv = document.getElementById('myDivId');
    console.log('the height is ' + getHeight(myDiv));
    

    [edit2]Keep in mind that the divs might actually have a different size depending on the browser.

    Let’s say this is google chrome and the green bar at top is the navigation bar, with a height of 75px. You have it at 100%, filling up your screen, who has 1000px height, and you place an 100 pixels div to the top and also stick an 100px div to the bottom of the screen (with blue). The purple div between them will have an 725px height.

    google chrome example

    And this below is firefox. It’s placed on the same 1000px screen, also at 100%, but its navigation bar has 100px height. With the same 100px blue divs to the top and the bottom, the purple div will have a height of 700px here, different from chrome.

    firefox example

    Of course, this is a very, very simple example and I doubt this is your case. But you might have a similar problem with div placements and it’s something you should try to check.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Back story i have a table that stores cached times, and currently has about
A little back story : I have small application that will use Word to
Back story: I have a class that handles a database query. The problem is
I have RaphaelJS based canvas, where user can do some work. I need to
The Back Story I have some decimal values which I am displaying as strings
I have some markup which contains the firebug hidden div. (long story short, the
So here's the story: I have a QListview that uses a QSqlQueryModel to fill
Long story short, I have a Java process that reads and writes data to/from
Long story short, VSS decided I wasn't allowed to have some code changes. I
Back story: Small-time iPhone developer, even have a (tiny) app on the App Store,

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.