Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window top and left position - can they be acquired? 1

Status
Not open for further replies.

XgrinderX

Programmer
Mar 27, 2001
225
US
Hello!

We have an application that pops up windows for different kinds of data displays. We use window.moveTo and window.resizeTo to control the beginning location and size of these windows.

Our users are asking if we can save settings such that when they move a window, the next time they open it, it will open in the position they moved it to.

Is there a way to grab the current window position? I know that 'top' and 'left' are options in the window.open features, but I can't find anything that says I can then grab those values later. Is there a way to get thos values after a user moves the window?

-Greg
 
In Internet Explorer you can use window.screenLeft and window.screenTop

Adam
 
AH! I kept looking in my JavaScript book under window.screen to se if there was a .top or .left value. I never looked for .screenTop or.screenLeft.

THANKS!!!
 
Also have a look at:
window.pageXOffset
window.pageYOffset

I can't quite work out from the explanation at if they'll do what you want, they might be just the scrolled-to location. Sure give it a go and let us know.

Try and avoid IE-only fixes unless you have a captive audience.

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
Try and avoid IE-only fixes unless you have a captive audience.

Yeah, as a matter of fact, this is an intranet application so we know that all the machines are going to be running IE.

I tried window.screenLeft and window.screenTop and they grab the initial values fine, but after the window is moved they seem to return useless numbers in the 100,000 range. And no matter where I move the window, they will always return the same value.

I will try the page offset properties tomorrow (Monday) and see if I can make them work. I'll let you know what I find out.

Thanks!

-Greg
 
Those page offset properties apply to the document within the window and return how many pixels the document has been scrolled.

So far I have not found any good way to determine top and left position after a window has been moved. Anyone else out there have any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top