/    Sign up×
Community /Pin to ProfileBookmark

How to get the screen size of the current screen in IE

Hello,

I have 2 monitors from a different size. It is important in my application that I get the screen size of the monitor where [B]the webbrowser is located[/B]. When I try to get the screen size (window.screen.height + window.screen.width) only IE gives me always the screen size of the main monitor where my taskbar (windows7) is located, instead of the screen size of the secondary screen where the webbrowser is located.

Does anybody knows a good workarround?

Thanks!

Christophe

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@WolfShadeMar 03.2011 — If you mean to get the screen resolution that the monitor is set to, I don't know about that.

However, if you need to check for screen dimension of the browser, itself, I use the following:
<i>
</i>function getWidth() {
if (typeof window.innerWidth != 'undefined') {
return window.innerWidth;
}
else if (typeof document.documentElement != 'undefined' &amp;&amp; typeof document.documentElement.clientWidth != 'undefined' &amp;&amp; document.documentElement.clientWidth != 0) {
return document.documentElement.clientWidth;
}
else {
return document.getElementsByTagName('body')[0].clientWidth;
}
}
function getHeight() {
if (typeof window.innerWidth != 'undefined')
{
return window.innerHeight;
}
else if (typeof document.documentElement != 'undefined'
&amp;&amp; typeof document.documentElement.clientWidth !=
'undefined' &amp;&amp; document.documentElement.clientWidth != 0) {
return document.documentElement.clientHeight;
}
else {
return document.getElementsByTagName('body')[0].clientHeight;
}
}



^_^
Copy linkTweet thisAlerts:
@Christophe27authorMar 12.2011 — Hello,

No I mean the actual screen height and width of the users screen in pixels. "window.screen.height" and "window.screen.width" works in all browsers, except Internet Explorer ...

Anybody?

Christophe
Copy linkTweet thisAlerts:
@rnd_meMar 13.2011 — to any robust web app, the browser size is a lot more important than the screen size.
Copy linkTweet thisAlerts:
@Christophe27authorMar 13.2011 — I really need the actual screen size at this time, but perhaps I can create a (serious) workarround using the inner width and height of the web browser.
Copy linkTweet thisAlerts:
@Christophe27authorMar 14.2011 — Thanks!?
×

Success!

Help @Christophe27 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.29,
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,
)...