Checking to see if browser is maximized

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Checking to see if browser is maximized

Post by nigma »

Could someone show me how to check to see if a browser has been maximized?
jollyjumper
Forum Contributor
Posts: 107
Joined: Sat Jan 25, 2003 11:03 am

Post by jollyjumper »

Hi Nigma,

I wouldn't know exactly how to check if the screen is maximized. What I do know is how to maximize the screen to the clients screen resolution.

Code: Select all

top.window.moveTo(0,0);
if (document.all) {
  top.window.resizeTo(screen.availWidth,screen.availHeight);
} else {
  if (document.layers||document.getElementById) {
    if top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)&#123;
      top.window.outerHeight = screen.availHeight;
      top.window.outerWidth = screen.availWidth;
    &#125;
  &#125;
&#125;
Hope this helps you a bit.

Greetz Jolly.
User avatar
trollll
Forum Contributor
Posts: 181
Joined: Tue Jun 10, 2003 11:56 pm
Location: Round Rock, TX
Contact:

Post by trollll »

If you detect the screen dimensions and then check the window dimensions (within a range, as different browsers tell you different things even if they should have the same dimensions), maybe? Something like:

Code: Select all

<script type="text/javascript">
var maximized = false;
if ((window.outerWidth + 25 > screen.availWidth) && (window.outerHeight + 25 > screen.availHeight)) &#123;
    maximized = true;
&#125;
</script>
It won't tell you if the user has clicked the "maximize" button on the window, but it will let you know if it has about the same dimensions as the screen and it should work with most browsers and OSs.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Thanks guys. I actually found a script on dynamic drive to maximize the browser but once the browser is maximized and then I go to another page that has the maximize code inside it, the browser like re-maximizes itself making the loading of the page weird. So I want to check to see if the browser is already maximized before using that code, like do a while loop.

while (maximized != 0)
{
// maximize browser code here
}
Gleeb
Forum Commoner
Posts: 87
Joined: Tue May 13, 2003 7:01 am
Location: UK
Contact:

Post by Gleeb »

An opinion:
Self maximising pages are annoying and often get confused for pr0n popups. They'll usually get closed. Don't do it.
elToro
Forum Newbie
Posts: 9
Joined: Fri Jun 27, 2003 10:31 am

Post by elToro »

Yeah, if you ever maximize my browser window, you'll live to regret it.

I run at 1600x1200, and people who run at high resolutions tend not to want something like a browser window taking up their entire screen. I have that particular JavaScript capability turned off, in fact. You're better off accepting that you don't have total control over people's browser windows.
jollyjumper
Forum Contributor
Posts: 107
Joined: Sat Jan 25, 2003 11:03 am

Post by jollyjumper »

I'm sorry, I've wetten my pants from laughing.

When my site would maximize your screen, you wouldn't visit it anymore, would I regret it? I probably wouldn't even know you ever visited it.

Greetz Jolly
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Any site that maximises the users browser is unlikely to have very many visitors staying for any length of time. I wouldn't visit twice and neither would a lot of other people. I personally would regret cutting out a lot of visitors just because I can't be bothered to design my site to deal with different resolutions and screen sizes in a user friendly way.

Mac
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

jollyjumper wrote:I'm sorry, I've wetten my pants from laughing.

When my site would maximize your screen, you wouldn't visit it anymore, would I regret it? I probably wouldn't even know you ever visited it.

Greetz Jolly
what's the point of your site?

if it is only for you, then you wont regret it, but if the point is to have it out there for others and you don't make it friendly to them, then you will regret it. why? you will be sending users away never to return
Post Reply