473,785 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find Window State - whether window is maximised or minimised

1 New Member
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 7104
acoder
16,027 Recognized Expert Moderator MVP
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 Recognized Expert Contributor
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 Recognized Expert Moderator MVP
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 Recognized Expert Contributor
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 Recognized Expert Moderator MVP
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
3352
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. Preferrably I'd like to use a Windows API to change the text displayed in the TASKBAR for the form window. Is it possible to change the title used by the taskbar to something different to the title used by the form window? Have been searching for...
10
3429
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 found the following script on a freescripts page to do just that... it works perfectly. Into head section:
1
1307
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 was minimized for example, I need to maximize it. How can I do that? Thanks, Jim.
17
1842
by: Geoff Cox | last post by:
Hello, Can I use JavaScript to force a maximised window ? Thanks
2
1198
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 width while the window is minimised? I want to save the state of my application windows, including those that are minimised, but I need to save the restore dimensions and not the minimised dimensions. TIA
0
1764
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 state not maximised. To accomplish this, in the activated event of my MainForm I first activated the other window and then activated my window. I've implemented the following piece of code in the activated event of my MainForm: private void...
4
4484
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 not available then I have to drag the corners to try and match the size for designing and setting up the controls. Altough ticking the option "Maximised" for the field WindowState, this doesn't have an effect in runtime and therefore controls can't...
1
1578
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 ' Does it's stuff fCloseApp ("XLMAIN") ' Close ALL versions of Excel, any spreadsheet Application.DoCmd.Maximize ' Why not
10
2515
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 window is in its "normal" state i.e. not maximised, and not minimised to the taskbar. We click each of the three taskbar buttons in turn and, of course, the three
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.