/    Sign up×
Community /Pin to ProfileBookmark

how to obtain the actual width and height of a modal dialog window

Hello

I have a modal dialog window which I triggered using:
window.showModalDialog()

in the HTML page that is rendered inside the window I place various controls.
I would like to know what is the final dimensions of the window. i.e what is the actual width and height (in pixels) that the window is occuppying on the screen.

I know that this information is browser specific as each browser renders its elements a bit different.

Still I hope that I have access to this information in the onload() event of the page.

Can someone show me how to obtain this info?
I tried:
document.body.clientHeight
document.body.scrollHeight

but both seem to not be affected by the amount of content in the page

regards

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@jasongrauthorOct 17.2004 — Here is a little trick that I tried:

I placed one big <div> element surrounding everything inside the <body> element like so:
<i>
</i>&lt;html&gt;
&lt;body&gt;
&lt;div id="container"&gt;
&lt;!-- content of page goes here --&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;


Later in onload() I do the following:
<i>
</i>var height = container.offsetHeight;
var width = container.offsetWidth;

These give me the minimal dimensions the window should have without scrollbars.

The problem starts when I try to update the width and height of the window to these new values:
<i>
</i>window.dialogHeight = height + "px";
window.dialogWidth = width + "px";

All of a sudden I got two scrollbars!

Can anyone see what the problem is?

What am I not taking into account?
Copy linkTweet thisAlerts:
@FangOct 18.2004 — 'Modal Dialog Boxes' are IE specific!

To find the dimensions of the modal window use [i]window.dialogHeight and window.dialogWidth[/i]

http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/showmodaldialog.asp
×

Success!

Help @jasongr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...