Retrouvez les publications relatives à ces discussions dans
notre rubrique javascript.
liste des forums
liste des discussions
Participer à la discussion
-
Message publié le mardi 22 juillet 2008 à 15 h 55 par grandpa006.
-
Bonjour,
Voila je voudrais recuperer l'ID de mes DIV en meme temps que le click de la souris mais j'y arrive pas.
Si une ame charitable a une idée se serait sympa.
Merci par avance :
-------- VOILA MON CODE -------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">.Style8 {font-size: 10px; font-family: Arial, Helvetica, sans-serif; }</style>
<script>
function sourisxy(obj,e)
{
id = obj.id;
x = (navigator.appName=="Netscape") ? e.pageX : event.x + document.body.scrollLeft;
y = (navigator.appName=="Netscape") ? e.pageY : event.y + document.body.scrollTop;
window.location.href="test3.html?x="+x +"&y="+y +"&id="+id;
}
if(navigator.appName.substring(0,3) == "Net")
document.body.captureEvents(Event.mousemove);
document.body.onclick = sourisxy;
</script>
</head>
<body onload="init();">
<div id="id1" onclick="sourisxy(this,e);" style="z-index: 1; margin-left: 0px; margin-top: 0px; opacity: 1; width: 160px; height: 125px; border: 1px dashed #900; background-color: red;position:relative;">
<div id="id2" onclick="sourisxy(this,e);" style="z-index: 2; margin-left: 0px; margin-top: 0px; opacity: 1; width: 160px; height: 50px; border: 1px dashed #900; background-color: yellow;position:absolute; top:50px;"></div>
<div id="id3" onclick="sourisxy(this,e);" style="z-index: 3; margin-left: 0px; margin-top: 0px; opacity: 1; width: 160px; height: 25px; border: 1px dashed #900; background-color: green;position:absolute; top:25px;"></div>
</div>
</body>
</html>
-
Message publié le mercredi 23 juillet 2008 à 21 h 25 par sprayart.
-
Bonsoir,
j'ai revu un peu ton code et ça devrait le faire. A+
----------------------------------------------------------------------------------------------
<head>
<style type="text/css">.Style8 {font-size: 10px; font-family: Arial, Helvetica, sans-serif; }</style>
<script language="javascript">
function sourisxy(objdiv)
{
alert(objdiv.id);
}
</script>
</head>
<body>
<form name="formulaire">
<div id="id1" onclick="sourisxy(this);" style="z-index: 1; margin-left: 0px; margin-top: 0px; opacity: 1; width: 160px; height: 125px; border: 1px dashed #900; background-color: red;position:relative;">
<div id="id2" onclick="sourisxy(this);" style="z-index: 2; margin-left: 0px; margin-top: 0px; opacity: 1; width: 160px; height: 50px; border: 1px dashed #900; background-color: yellow;position:absolute; top:50px;"></div>
<div id="id3" onclick="sourisxy(this);" style="z-index: 3; margin-left: 0px; margin-top: 0px; opacity: 1; width: 160px; height: 25px; border: 1px dashed #900; background-color: green;position:absolute; top:25px;"></div>
</form>
</body>
</html>
liste des forums
liste des discussions
Participer à la discussion
Vous devez obligatoirement vous identifier en tant que membre pour participer à cette discussion.