Click to See Complete Forum and Search --> : Window and mouse position


Paco Zarabozo
01-27-2003, 06:11 PM
Hi. I'm going crazy trying to find how to do this, i hope someone here can tell me how to do it. I'm sure it's pretty simple, but i just can't find the way to do it.

I need to get two values.

1. Mouse position ON THE WHOLE SCREEN, NOT IN THE CURRENT WINDOW.

2. Window position ON THE WHOLE SCREEN.

Far away, all i've found on this area is how to specify the window position with window.moveTo(x, y), but what i need is to get the current window position before using this.

For the mouse, all i've found is how to know the mouse position on the current window with window.event.clientX and window.event.clientY, but i need to know the mouse position on the screen, not only on that window.

Thanks in advance.
Paco.

Paco Zarabozo
01-27-2003, 07:02 PM
Thanks for your answer Dave.

I know i can't get information about the mouse outside of the window, but actually, i want to get that position while the mouse is over the window.

What i'm trying to do, is to move a window with the mouse and make it responde like a regular window. The thing is that i'm opening a fullscreen window, then resizing it to 200x200px, and trying to emulate a title bar which you can take with your mouse to move the window.

I had a successful try, taking as reference the position of the mouse when i do the mousedown on the title bar and moving the window with moveBy() according to where the mouse is now. It works, but if i move the mouse too fast, it looses the window and the window stops moving.

I saw a script which does this very effectively, the window is moved perfectly binded to the mouse and it never looses the window; but i just couldn't understand the source code. If you want to see it working, go to http://www.galeza.com/chromeless/example/test_html.html and click on the examples. I think it doesn't work with IE6, but i'm not sure. It works perfectly with IE5.

Thanks Dave.

Paco Zarabozo
01-27-2003, 07:16 PM
Dave! Guess what?

Accidentally, by trying your netscape example and writing it wrong, i discovered the way to know the mouse position on the entire screen using IE5.5!

window.event.screenX

That gives you the mouse position on the screen, but of course, only if you're over the window. I guess this resolves one of my questions. Now, all i need to know is the window's position... but as you told me before, maybe IE doesn't supply this info.

Is there a way to obtain the posible methods or properties of an object? Sometimes, while trying things, i discover objects that are printed as [object], but then i have to find out what can i do with it. For example, i discovered that window.screen is a valid object, but i don't know what can i do with it.

Paco.

Charles
01-27-2003, 07:30 PM
What would Jesus do?Mark 10:21 (NRSV):
Jesus, looking at him, loved him and said, "you lack one thing; go, sell what you own, and give the money to the poor, and you will have treasure in heaven; then come, follow me."

Jona
01-27-2003, 07:36 PM
Charles: you did mean that in the right way, didn't you? Just making sure. Are you a Christian? I am.

Paco Zarabozo
01-27-2003, 07:49 PM
Dave:

Look at this page. You'll find some very interesting things. Go to http://microbians.com and select from the pull down menu "DRAG ACROSS WINDOWS". It seems to detect the window position and it's made for IE. Drag the image or move one window. I was very impresed with it. At first i saw it and i said "very cleaver, still easy i think"... but know i think it's not that easy.

This page is the personal projects page from the creator of the chromeless window. A very talentive guy.

Paco.

khalidali63
01-27-2003, 07:56 PM
Yes you can get the screen resolution as well as the window size try this code segment.


function process(){
var ww = (document.all)?document.body.offsetWidth :window.innerWidth;
var wh = (document.all)?document.body.offsetHeight :window.innerHeight;
var sw = window.screen.availWidth;
var sh = window.screen.availHeight;
alert("Window\nW = "+ww+", H = "+wh+"\nScreen W = "+sw+", H = "+sh);
}
</script>
</head>

<body onload="process();">function


cheers



Khalid

Charles
01-27-2003, 08:03 PM
I don't know what you mean by "in the right way". Where I live I see a lot of very rich people walking around with WWJD&trade; written on their clothing. It's kind of ironic when you think about how likely it is that Jesus would spend money on such a product.

Am I a Christian? Kierkegaard used the name Ante-climicus when he was writing from the heart - "Ante" as in ante-room and "Climicus" as in Johannes Climacus the great Eastern, Christian Mystic. (And Kierkagaard's dissertation was entitled The concept of Irony) Let's just say that I hope one day to advance to being a Christian.

Paco Zarabozo
01-27-2003, 08:17 PM
Dave:

I found the way to know the window position on the screen with IE. However, it detects the position of the working area, not the real window position; but taking on count that i'm going to use it with a fullscreen window, it works for me:

window.screenLeft
window.screenTop

Those are the parameters i think i was looking for. :-)

Paco.