🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.javascript
3 messages
3 total messages Started by Piotr Borowski Tue, 12 Jan 2010 17:05
pozycja kursora myszy
#49676
Author: Piotr Borowski
Date: Tue, 12 Jan 2010 17:05
21 lines
1433 bytes
Witam
mam div-a on id imgPrv
zrobilem funkcje odczytujaca w onMouseOver

function showImagePreview(event)
{
 x=event.screenX;
 y=event.screenY;
 alert("X=" + x + " Y=" + y + " a=");
 imgPrv = document.getElementById('imgPreview');
 imgPrv.style.visibility = 'visible';
 imgPrv.style.position = 'absolute';
 imgPrv.style.top = y + 'px';
 imgPrv.style.left = x + 'px';
}

tyle, ze div ukazuje sie przesuniety o tyle o ile okienko jest przesuniete, 
chyba musze odczytac pozycje okna i odjac od pozycji myszy, ale nie mogle 
znalezc jak, spedzilem ponad godzine szukajac w internecie

prosze o pomoc 
Re: pozycja kursora myszy
#49677
Author: Paweł Arciszewski
Date: Tue, 12 Jan 2010 19:02
35 lines
2327 bytes
On 12 Sty, 18:05, "Piotr Borowski" <birst...@gazeta.pl> wrote:
> Witam
> mam div-a on id imgPrv
> zrobilem funkcje odczytujaca w onMouseOver
>
> function showImagePreview(event)
> {
>  x=event.screenX;
>  y=event.screenY;
>  alert("X=" + x + " Y=" + y + " a=");
>  imgPrv = document.getElementById('imgPreview');
>  imgPrv.style.visibility = 'visible';
>  imgPrv.style.position = 'absolute';
>  imgPrv.style.top = y + 'px';
>  imgPrv.style.left = x + 'px';
>
> }
>
> tyle, ze div ukazuje sie przesuniety o tyle o ile okienko jest przesuniete,
> chyba musze odczytac pozycje okna i odjac od pozycji myszy, ale nie mogle
> znalezc jak, spedzilem ponad godzine szukajac w internecie
>
> prosze o pomoc

ta funkcja powinna pomóc:

function getMouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}
Re: pozycja kursora myszy
#49678
Author: Piotr Borowski
Date: Wed, 13 Jan 2010 09:41
25 lines
1751 bytes
----- Original Message ----- 
From: "Pawel Arciszewski" <p.arciszewski@archol.pl>
Newsgroups: pl.comp.lang.javascript
Sent: Tuesday, January 12, 2010 7:02 PM
Subject: Re: pozycja kursora myszy

> On 12 Sty, 18:05, "Piotr Borowski" <birst...@gazeta.pl> wrote:
>> prosze o pomoc
>
> ta funkcja powinna pomóc:
>
> function getMouseCoords(ev){
> if(ev.pageX || ev.pageY){
> return {x:ev.pageX, y:ev.pageY};
> }
> return {
> x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
> y:ev.clientY + document.body.scrollTop  - document.body.clientTop
> };
> }

dzieki, pomoglo
juz sie zabieralem za wytoczenie armaty w postaci prototype.js
ale wiedzialem, ze musi byc jakas prostsza metoda
jeszcze raz dzieki 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads