Newsgroup: it.comp.lang.javascript
Titolo: OnMouseOn e OnMouseOut (qual'è l'oggetto che ha generato l'evento?)

 Nella mia pagina ci sono una serie di link come questo:
<A name="6" href="#" onclick="javascript:parent.FRAMEMAIN.DelSel();"
onmouseover="m_over()"
onmouseout="m_out()"><%=GetString(ConstLabLogDel(0))%></A>
.................................................
.....................................................
a cui sono associati eventi di MouseOut e MouseOver. In IE le funzioni
associate funzionano, ma in Netscape no perchè il riferimento all'oggetto
che ha generato l'evento non corrisponde.
<SCRIPT LANGUAGE=javascript>
<!--
 function m_out(x) {
  if (x==null)
  x=window;
   x.event.srcElement.style.background="<%=ConstBgColorTopOut%>";
   x.event.srcElement.style.color="<%=ConstFgColorTopOut%>";
 }
 function m_over(x) {
   if (x==null)
  x=window;
   x.event.srcElement.style.background="<%=ConstBgColorTopOver%>";
   x.event.srcElement.style.color="<%=ConstFgColorTopOver%>";
 }
file://-->
</SCRIPT>
Qual'è la sintassi esatta per Netscape?
Ciao.
:-) e-manuel

    x.event.srcElement.style.color="<%=ConstFgColorTopOut%>";
Ciao!
event.srcElement ..per IE
event.target.....per NN
____________________
andreotta fabiano
WebMªster ATI POWER s.n.c.
andr...@atipower.it
http://www.atipower.it
http://www.afdsoftware.freeweb.org
____________________
*¢ L'unica certezza nella vita è che tutto è relativo (per fortuna)¢*

 wrote in message
news:8p5m9n$ivr$1...@worldonline.it...



Questo è un esempio di utilizzo di   .srcElement  e   .target  che funxia
però solo per IE 5.5 e NN6............
<html>
<head>
<title>Exclusive Hover Buttons</title>
<script type="text/javascript">
 // Version-5 Browsers only.
 // Browser patch for missing W3C DOM Event.target call
 // in IE5; returns the object that is the source of the event.
 function getTarget(e) {
  // IE5
  if (e.srcElement) {
   return e.srcElement
  }
  // NC5
  if (e.target) {
   return e.target
  }
 }
 // The bulk of this module is taken up with handling the mutually-
 // exclusive visual effects of clicking a button. The action handler
 // is only window.status write. Modify that for your actual needs.
 function clickWhich(e) {
  // Lo-lite all buttons.
  for (var i = 0; i < document.getElementsByName('set1').length; i++) {
   // Button
   document.getElementsByName('set1').item(i).className = "normal"
   // Label
   document.getElementsByName('set1').item(i).parentNode.className =
"normal"
  }
  // Select the clicked button.
   // Button
  getTarget(e).className = "active"
   // Label
  getTarget(e).parentNode.className = "active"
         // Here's where the real action goes.
         window.status = "You clicked: " + getTarget(e).id
 }
 // This module handles the mutually-exclusive visual effects of
 // a mouseover.
 function overWhich(e) {
  // Lo-lite all buttons, unless one is active.
  for (var i = 0; i < document.getElementsByName('set1').length; i++) {
   // If the button is not active...
   if ( document.getElementsByName('set1').item(i).className != "active" ) {
    // Button
    document.getElementsByName('set1').item(i).className = "normal"
    // Label
    document.getElementsByName('set1').item(i).parentNode.className =
"normal"
   }
   // Hi-lite the hover button.
   if ( getTarget(e).className != "active" ) {
    // Button
    getTarget(e).className = "hover"
    // Label
    getTarget(e).parentNode.className = "hover"
   }
  }
 }
</script>
<style>
 label.hover {
  background-color: blue;
  width: 100px;
 }
 button.hover {
  background-color: aqua;
  color: blue;
 }
 label.active {
  background-color: aqua;
  width: 100px;
 }
 button.active {
  background-color: blue;
  color: white;
 }
 label.normal {
  background-color: black;
  width: 100px;
 }
 button.normal {
  background-color: gray;
  color: aqua;
 }
</style>
</head><body onmouseover="javascript: overWhich(event);"
onclick="javascript: clickWhich(event);">
<img src="w3cdom.gif"> This page is for Navigator version 5 or Explorer
version 5.5<em>only</em>.
<form name="form0">
<label id="l0" name="lab1" class="normal">
<button name="set1" class="normal" id="b0">0</button>
Zeroth</label>
<br>
<label id="l1" name="lab1" class="normal">
<button name="set1" class="normal" id="b1">1</button>
Oneth</label>
<br>
<label id="l2" name="lab1" class="normal">
<button name="set1" class="normal" id="b2">2</button>
Secondth</label>
<br>
<label id="l3" name="lab1" class="normal">
<button name="set1" class="normal" id="b3">3</button>
Thirdth</label>
<br>
</form>
</body>
</html>
