Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: IE AND NETSCAPE


Message #1 by "Claudio Pallone" <pallone@l...> on Sun, 22 Sep 2002 23:44:26 +0100
Hi Claudio

Could you explain a little more about what you are trying to do generally
and what effect you are trying to achieve

Thanks
Phil


> Hi,

I have a javascript function that works fine in IE but not in Netscape. I
build the Class and ID like this:

<td nowrap="" valign="top">
    <img src="images/icon_plus.gif" CLASS="Level1Button" 
style="cursor:hand"
id="1+"></img>
  </td>

Then on the document.onclick I call the function doOutline and get the
srcElement (Class="Level1Button")  unisng the window.event.srcElement.

Does Netscape understand this: srcElement = window.event.srcElement ?? if
not could someone help me to find the equivalent in netscape or maybe a
method with is accepted by both browsers!!

Also, in IE I check the value of the srcElement (Class="Level1Button")
using this code:  if (srcElement.className == "Level1Button"). Does 
netscape
understand the class.Name property????

Another problem is that I am using the document.onclick = doOutline; to 
call
the function but I think this is not elegant. How could I pass both the ID
and Class of my image tag to my function? if possible in a way that both
browsers would accept??

Cheers,

Claudio

This is the function:

<script language="JavaScript">
<!--
//Associate the event handler function with the onclick event
document.onclick = doOutline;

function doOutline()
{
 var baseID, srcID, targetID, srcElement, targetElement;

 srcElement = window.event.srcElement
   if (srcElement.className == "Level1Button")
   {
  srcID = srcElement.id;
  baseID = srcID.substr(0, srcID.length-1);
  targetID = "Group_" + baseID;

  targetElement = document.all(targetID);

  if (targetElement.style.display == "none")
  {
   targetElement.style.display = "";
   srcElement.src = "images/icon_minus.gif";
  }
  else
  {
   targetElement.style.display = "none";
   srcElement.src = "images/icon_plus.gif";
  }
 }
}
//-->
</script>



  Return to Index