0

I am using IE 11 , and it fails to render div dialog properly. All the dimensions viz. height, width, top, left give inappropriate results. The same is working fine for IE10.

The javascript code snippet is as follows:-

if (height > 0 && width > 0)
{
    myDialog.height = height;
    myDialog.width = width;
    myDialog.top = (parseInt(document.body.clientHeight) - height) / 3;
    myDialog.left = (parseInt(document.body.clientWidth) - width) / 2;
}  

Here, myDialog is the div object I am talking about. why is this code snippet failing for IE11. Any help is appreciated.

1
  • 1
    Depends on a lot of things you haven't posted, but the most important is, that width and height properties for div are obsoleted. Commented Nov 27, 2013 at 12:20

2 Answers 2

1

You're setting properties on the HTMLDivElement instance. You may have more success setting them on its style property:

if (height > 0 && width > 0)
{
    myDialog.style.height = height + "px";
    myDialog.style.width = width + "px";
    myDialog.style.top = ((parseInt(document.body.clientHeight) - height) / 3)  + "px";
    myDialog.style.left = ((parseInt(document.body.clientWidth) - width) / 2)  + "px";
}  

Note I've also added px to the end, since these are CSS-style measurements.

Sign up to request clarification or add additional context in comments.

Comments

0

try following

if (height > 0 && width > 0)

{

myDialog.style.height = height;
myDialog.style.width = width;
myDialog.style.top = (parseInt(document.body.clientHeight) - height) / 3;
myDialog.style.left = (parseInt(document.body.clientWidth) - width) / 2;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.