views:

52

answers:

3

How do I get in Internet Explorer values equivalent to: window.screenX and window.screenY in Firefox ? I've seen some "solution": window.screenLeft and window.screenTop but it is not correct. These properties give inner coordinates.

I move a window and I need values to use with window.moveTo() to restore the original location.

A: 

Equivalent properties don't appear to exist for Internet Explorer windows. Have you seen the window.resizeBy(w, h) method? Using that you could grow by a specific amount and then shrink back down using negative values (or vice versa):

window.resizeBy(300, 300);  // expand window by 300x300 pixels

window.setTimeout(function ()
{
    window.resizeBy(-300, -300); // back to original size
}, 10000);
Andy E
Sorry, I messed the question and edited it. Looks like you were answering the original meanwhile.
Ilya
A: 

There are years since i did any MSIE programming, but i roughly remember using something like this

  • save screenLeft and Top as window postion (this is wrong but read on)
  • when restoring the position, window.moveTo(saved position)
  • (current screenLeft > saved Left) window.moveBy(-1,0)
  • the same for y position

the idea is that we place the window in a wrong position first and then correct it step by step

stereofrog
Thanks! I'll try a bit later some solution based on this idea. I'm thinking about moving the window to the wrong position, calculating the diff and moving once again.
Ilya
My code based on your ideas seems to work for now. Thanks again!
Ilya
A: 
var saveLeft = window.screenLeft;
var saveTop = window.screenTop;
window.moveTo(saveLeft, saveTop);
var savePos = [
    saveLeft + (saveLeft - window.screenLeft), 
    saveTop + (saveTop - window.screenTop)
];

Seems to work

Ilya
Then you go and move the window however you want. When you want to restore the original position use window.moveTo(savePos[0], savePos[1]) .
Ilya