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 3334326
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:53:34+00:00 2026-05-17T23:53:34+00:00

In some versions of IE, there is a thin 2px border surrounding the document

  • 0

In some versions of IE, there is a thin 2px border surrounding the document view port. I haven’t noticed it for any other browsers yet. This poses a slight problem in calculating mouse positions for the page and client areas. Originally, I simply subtracted 2 from each of the calculations to account for the border.

But then, when I tested it in different versions of IE and different IE embedding programs, I noticed that in some cases, there is no border. So, simply doing a check for IE and subtracting 2 won’t cut it.

Is there any way of getting the document view port border in IE?

Example1: finding mouse position inside object

<html>
<head>
    <script>
        var isIE = (!window.addEventListener);
        window.onload = function(){
            var foo = document.getElementById('foo');
            if (isIE) foo.attachEvent('onmousemove',check_coords);
            else foo.addEventListener('mousemove',check_coords,false);
        }
        function check_coords(e){
            var foo = document.getElementById('foo');
            var objPos = getPos(foo);
            if (isIE) mObj = [window.event.clientX+document.body.scrollLeft-objPos[0], window.event.clientY+document.body.scrollTop-objPos[1]];
            else mObj = [e.pageX-objPos[0], e.pageY-objPos[1]];
            foo.innerHTML = mObj;
        }
        function getPos(obj){
            var pos = [0,0];
            while (obj.offsetParent){
                pos[0] += obj.offsetLeft;
                pos[1] += obj.offsetTop;
                obj = obj.offsetParent;
            }
            return pos;
        }
    </script>
    <style>
        body{
            margin:0px;
            padding:0px;
        }
        #foo{
            border:3px solid black;
            position:absolute;
            left:30px;
            top:52px;
            width:300px;
            height:800px;
            background-color:yellow;
        }
    </style>
</head>
<body>
    <div id='foo'>Test test</div>
</body>
</html>

At coordinate [0,0], Internet Explorer (the one’s that have the border) returns [2,2]

Example2: getting scrollbar width

alert(screen.width-document.body.clientWidth);

With a scrollbar width of 17px, Internet Explorer (versions that have the border) returns 21px, not accounting for the 2px borders on each side.

UPDATE:
So, I guess it actually was a default style that is applied to the body tag. Sorry guys! I had originally done a document.body.style.borderWidth to check if it was a css style. But I just realized a couple minutes ago, that I should have done document.body.currentStyle['borderWidth']. This returns medium. So, the correct way to get the viewport border without modifying the page (this ONLY applies to IE calculations), you will need to use .currentStyle['borderWidth']. The script appears to work in all other browsers, besides IE, without performing the border check (as far as I have checked). Furthermore, you only have to check for borderWidth in IE- padding or margin don’t seem to matter. Also, when subtracting border-widths, make sure you’re checking for borderTopWidth AND borderLeftWidth.

Anyways, I awarded the bounty to Samuel, since he was the first to mention it might be a default browser style.

  • 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-17T23:53:34+00:00Added an answer on May 17, 2026 at 11:53 pm

    Are you sure it isn’t the style of the body tag? I know that some browsers have a default style to the body tag.
    To be safe I always put

    body{
        padding:0px;
        margin:0px;
    }
    

    in my stylesheet

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

Sidebar

Related Questions

In earlier versions of the tt_news plugin there was some configuration in the flex
In some versions of UNIX and Linux there's a banner command (usually /usr/bin/banner) that
Is there a problem with some versions of PHP and file names which look
My project isn't complete, but I'd like to distribute some demo versions. Is there
Task at hand — I have three versions of some code, developed by different
I am experiencing a problem with the following code in some versions of Internet
I have an application which supports multiple types and versions of some devices. It
Version Dependent Some of the answers to this question deal with older versions of
I'm trying to hide some unused journals. It seems in older versions, journals had
I have contemplating how to handle paper document input in Webapps for some time.

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.