Hi, I am using this script to capture the event when a user shuts down the webbrowser window using the "X". But is there anyone that can explain what "screenTop" actually do that makes this work?
In Internet Explorer screenTop is used to determine the x and y coordinates of the windows position in relation to the users monitor screen. It has nothing to do with the closing of the screen and it is an IE only property.
It's hard to think outside the box when I'm trapped in a cubicle. In an increasingly self-focused society it is important to recognize the unselfish actions of others so they will feel encouraged to continue such actions. Please give acknowledgement to those who aid you whether it is waving to the person who let you out in traffic, tha
I made a little mistake in my first post. screenLeft is the property for the x coordinate while screenTop is the property for the y coordinate. I stated it as if screenTop did both.
screenTop in the link you show above returns the number of pixels from the top of the monitor display screen the content window of the IE page starts.
For instance, if my IE window is flush with the top of my monitor display screenTop reports a value of 128, meaning there are 128 pixels between the top of the monitor display and where the content window begins. The space in between is taken up by the top of the IE browser window and the toolbars. If I move the window down from the top edge of the monitor display the value of screenTop increases by the same number of pixels.
In the case of a line like this:
< body onunload = "if (screenTop > 9999) alert('Closing');">
When the page begins to unload the code says:
If the content window starts at more than 9999 pixels from the top of the screen then send an alert.
Realistically, your content window will not be that far down the screen as your monitor is not going to display that many pixels anyway. Most likely the person using this code was setting his window position to be way below the actual displayable screen. Probably the window was not meant to be visible but to remain open for other reasons and when the page is closed it tests if the page is in it's off-screen position and sends the alert.
For your use you do not need the if statment, just use something like:
<body onunload="alert('closing');">
Again, the screenTop property is an IE only property. Using it with other browsers will not get you the same results because screenTop would not have a value so the if statement would not evaluate and trigger the alert.
It's hard to think outside the box when I'm trapped in a cubicle. In an increasingly self-focused society it is important to recognize the unselfish actions of others so they will feel encouraged to continue such actions. Please give acknowledgement to those who aid you whether it is waving to the person who let you out in traffic, tha
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.