473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Find Window State - whether window is maximised or minimised

How to find a window sate in Java Script ? I want to know whether the window is maximized or minimized ?
Mar 7 '08 #1
5 7075
acoder
16,027 Expert Mod 8TB
I'm not sure if this can be done reliably, but you can try finding the size of the window and determine from that whether it's minimised or maximised or otherwise. This link should help.
Mar 7 '08 #2
rnd me
427 Expert 256MB
a coder was close.

alert(screenX)

when minimized, you get -32000 in firefox.
when maximized, you get -4
when restored, you get something else (the position)
Mar 8 '08 #3
acoder
16,027 Expert Mod 8TB
a coder was close.

alert(screenX)

when minimized, you get -32000 in firefox.
when maximized, you get -4
when restored, you get something else (the position)
Interesting. Do you know what the values are in other browsers? Is there any sort of consistency in this inconsistency (if you know what I mean)?
Mar 8 '08 #4
rnd me
427 Expert 256MB
i was getting tired so i only tested in firebug last night.

here is a test case for your browser.
it seems ok in IE7 and FF2 for me.

Expand|Select|Wrap|Line Numbers
  1. <html><head><title>dans windowstate tester</title></head><body>
  2.  
  3. announce window state in 4 seconds  <input type='button'  id='' name='' onclick="doMin()" value='run' />
  4.  
  5. <script type='text/javascript'>
  6.         function getWindowState() {
  7.             var S = window.screenLeft;
  8.             if (typeof S === 'undefined' ) {
  9.                 S = window.screenX;
  10.             }
  11.         S=parseInt(S);
  12.             if (S < -4000) {
  13.                 return "minimized";
  14.             }
  15.             if (S > -8 && S < 1 ) {
  16.                 return "maximized";
  17.             }
  18.             return "restored:  " + S;
  19.         }
  20.  
  21.        function doMin() {
  22.            document.title = "change the window state now to what you want to test" 
  23.             setTimeout(" document.title=getWindowState(); ", 4000);
  24.         }
  25.  
  26. </script></body>    </html>    
Mar 8 '08 #5
acoder
16,027 Expert Mod 8TB
here is a test case for your browser.
it seems ok in IE7 and FF2 for me.
It also works in Safari. In Opera, it works with minimized, but not maximized (gives a value of 649).
Mar 9 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Shayne H | last post by:
I want to be able to add a clock to the title of a VB.NET form. Simply updating the FormClass.Text property does not quite make it, the titile only changes once the form is minimised/maximised....
10
by: -DRB- | last post by:
Hi all, I'm very much an amateur designing a page (for free!) for a friend, so any help offered would be hugely appreciated. I'm aiming to open a maximised window (and isn't that fun...) and...
1
by: JIM.H. | last post by:
Hello, I have a timer running in my windows .net application. While users are working with the other applications I need to bring focus to this application when timer elapses. If the application...
17
by: Geoff Cox | last post by:
Hello, Can I use JavaScript to force a maximised window ? Thanks
2
by: Charles Law | last post by:
When an MDI child window is minimised its height attribute returns 24 (on my system), but when it is restored it goes back to its former height (and width). How can I get the restore height and...
0
by: pavan377 | last post by:
Hi folks, I got a requirement in my project where in when my application is activated another window should get activated and upon it my application should be present. Both should be in restored...
4
by: tamasumalta | last post by:
I am just new to vb.net. I used to program in vb 6. Can you kindly indicate how I can maximise a form window to full in runtime. I think this is a standard thing to design controls. If this is...
1
by: Phil Stanton | last post by:
Here is a bit of code which opens an Excel file from a hyperlink activated on a form command button CreateHyperlink Me!Storage, "", ExcelPath ' Open Excel using Hyperlink DoEvents ...
10
by: Mark Rae [MVP] | last post by:
Hi, This is really just a theoretical question for my own interest, and not for any nefarious purpose... :-) Say we have three applications running - Notepad, Wordpad and Excel - and each...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.