Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > HTML, Javascript y otros
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 16-04-2009
Avatar de gabrielflowers
gabrielflowers gabrielflowers is offline
Miembro
 
Registrado: jul 2007
Posts: 88
Poder: 17
gabrielflowers Va por buen camino
coordenadas actual del mouse?

hola amigos, tengo una pregunta, como puedo obtener las coordenadas actuales del mouse?
...bueno se que se hace de la sgte manera:
<script language="javascript">
var x=event.clientX;
var y=event.clientY;
alert(x + ' ; ' + y);
</script>...

y funciona bien en explorer y en opera al parecer, mas no funciona en firefox!!!
alguien me puede dar una solucion que sea compatible con firefox (y el resto de navegadores)
gracias, saludos...
__________________
"valor a pesar de toda debilidad del cuerpo, el espiritu debe triunfar"
Responder Con Cita
  #2  
Antiguo 12-11-2009
Avatar de winzo
winzo winzo is offline
Miembro
 
Registrado: abr 2008
Ubicación: DF
Posts: 281
Poder: 17
winzo Va por buen camino
Respuesta en inglés

Ah, I see the problem. You are using Microsoft's Document Object Model. This works in IE 4+, Opera and Konqeuror.
I have modified your code so that it should work in IE DOM friendly browsers and W3C DOM friendly browsers (such as Mozilla, Netscape and Epiphany).
In actual fact you need only use the W3C DOM as this will work in IE 5+, Opera and Konqueor etc anyway, but I've left the IE DOM in case you're catering for IE4 users.
Click anywhere on the page to get the pop up message, move the mouse to lose it.
I don't use Windows so have not tested it in IE but it does work using .all under Konqueror and using getElementById in a variety of browsers.

HTH

<html>
<head>
<title></title>
</head>
<body>
<script language="javascript" type="text/javascript">

document.write("<div id='tip' style='position:absolute;visibility:hidden;left:10 0;top:100'><table borderstyle=outset border=0 bgcolor=#00c00c bordercolor=#ffffff><td id=message><br></td></table></div>");

function tip(msg,myEvent)
{
// check for IE4+ DOM and W3C DOM
scope = document.all? document.all.message : document.getElementById("message");

scope.innerHTML="<font color=#FFFFFF size=2 face=arial>"+msg+"</font>";

// check for IE4+ DOM and W3C DOM
twnd= document.all? document.all.tip : document.getElementById("tip");
twnd.style.visibility="visible";
twnd.style.top=myEvent.clientY+19;
twnd.style.left=myEvent.clientX-2;
}

function hide(){
twnd= document.all? document.all.tip : document.getElementById("tip");
twnd.style.visibility="hidden";
}

</script>
<body onClick="tip('Hello',event)" onMouseMove="hide()">
</body>
</html>


pero funciona!!!!!!
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Mapa de Coordenadas Luis Cuenca Gráficos 8 27-06-2023 05:07:53
Tchart y cálculo de valores en coordenadas del ratón (mouse) fonx Gráficos 9 18-07-2008 00:26:27
Iframe con coordenadas lKinGl PHP 2 21-05-2008 04:19:27
pasar coordenadas gps a coordenadas builder iaav1 C++ Builder 3 03-07-2006 19:59:02
Representar coordenadas 3D blueicaro OOP 5 20-04-2006 17:03:14


La franja horaria es GMT +2. Ahora son las 12:33:55.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi