mayonaise
10-04-2004, 03:42 PM
i have several DIVs that i would like to hilight onMouseOver. the script works perfectly in firefox, opera, and SOMETIMES in IE. the example below does not work! what doesn't work about it? they will only hilight when the mouse moves over the link inside of the DIV, and not simply when the mouse moves over any part of the DIV itself
the modified section of code farther below DOES work.
code example:
<html>
<head>
<title>IE sucks</title>
<style> <!--
.sideBar {
position: absolute;
visibility: visible;
width: 150;
left: 0;
top: 67;
z-index: 0;
}
--> </style>
<script language="javascript"> <!--
function backgroundOn(name)
{
document.getElementById(name).style.backgroundColor = "#F0A61A"
}
function backgroundOff(name)
{
document.getElementById(name).style.backgroundColor = "transparent";
}
// -->
</script>
</head>
<body text="#454545" alink="#EEEEEE" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div class="home">
<font face="arial,helvetica" size="2">
<div class="sideBar">
<div id="sideMenu" class="bgDark">
<div id="sideHeader"><STRONG>Home</STRONG></div>
<A id="sideLink" HREF="?section=home&page=news">
<DIV class="sideItem" id="sideItem_news" onMouseOver="backgroundOn('sideItem_news')" onMouseOut="backgroundOff('sideItem_news')">
news
</DIV>
</A>
<A id="sideLink" HREF="?section=home&page=policies">
<DIV class="sideItem" id="sideItem_policies" onMouseOver="backgroundOn('sideItem_policies')" onMouseOut="backgroundOff('sideItem_policies')">
policies
</DIV>
</A>
<A id="sideLink" HREF="?section=home&page=policies#rights">
<DIV class="sideItem" id="sideItem_rights" onMouseOver="backgroundOn('sideItem_rights')" onMouseOut="backgroundOff('sideItem_rights')">
student's rights
</DIV>
</A>
<A id="sideLink" HREF="?section=about&page=contact">
<DIV class="sideItem" id="sideItem_contact" onMouseOver="backgroundOn('sideItem_contact')" onMouseOut="backgroundOff('sideItem_contact')">
contact us
</DIV>
</A>
</div>
</div>
</font>
</div>
</body>
</html>
by either removing the lines noted below, OR removing all of the attributes from the .sideBar style, the hilighting works properly. I DON'T GET IT!!! again, this works perfectly in opera and firefox.
<!-- remove this line - <div class="sideBar"> -->
<div id="sideMenu" class="bgDark">
<div id="sideHeader"><STRONG>Home</STRONG></div>
<A id="sideLink" HREF="?section=home&page=news">
<DIV class="sideItem" id="sideItem_news" onMouseOver="backgroundOn('sideItem_news')" onMouseOut="backgroundOff('sideItem_news')">
news
</DIV>
</A>
<A id="sideLink" HREF="?section=home&page=policies">
<DIV class="sideItem" id="sideItem_policies" onMouseOver="backgroundOn('sideItem_policies')" onMouseOut="backgroundOff('sideItem_policies')">
policies
</DIV>
</A>
<A id="sideLink" HREF="?section=home&page=policies#rights">
<DIV class="sideItem" id="sideItem_rights" onMouseOver="backgroundOn('sideItem_rights')" onMouseOut="backgroundOff('sideItem_rights')">
student's rights
</DIV>
</A>
<A id="sideLink" HREF="?section=about&page=contact">
<DIV class="sideItem" id="sideItem_contact" onMouseOver="backgroundOn('sideItem_contact')" onMouseOut="backgroundOff('sideItem_contact')">
contact us
</DIV>
</A>
</div>
<!-- remove this line - </div> -->
the modified section of code farther below DOES work.
code example:
<html>
<head>
<title>IE sucks</title>
<style> <!--
.sideBar {
position: absolute;
visibility: visible;
width: 150;
left: 0;
top: 67;
z-index: 0;
}
--> </style>
<script language="javascript"> <!--
function backgroundOn(name)
{
document.getElementById(name).style.backgroundColor = "#F0A61A"
}
function backgroundOff(name)
{
document.getElementById(name).style.backgroundColor = "transparent";
}
// -->
</script>
</head>
<body text="#454545" alink="#EEEEEE" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div class="home">
<font face="arial,helvetica" size="2">
<div class="sideBar">
<div id="sideMenu" class="bgDark">
<div id="sideHeader"><STRONG>Home</STRONG></div>
<A id="sideLink" HREF="?section=home&page=news">
<DIV class="sideItem" id="sideItem_news" onMouseOver="backgroundOn('sideItem_news')" onMouseOut="backgroundOff('sideItem_news')">
news
</DIV>
</A>
<A id="sideLink" HREF="?section=home&page=policies">
<DIV class="sideItem" id="sideItem_policies" onMouseOver="backgroundOn('sideItem_policies')" onMouseOut="backgroundOff('sideItem_policies')">
policies
</DIV>
</A>
<A id="sideLink" HREF="?section=home&page=policies#rights">
<DIV class="sideItem" id="sideItem_rights" onMouseOver="backgroundOn('sideItem_rights')" onMouseOut="backgroundOff('sideItem_rights')">
student's rights
</DIV>
</A>
<A id="sideLink" HREF="?section=about&page=contact">
<DIV class="sideItem" id="sideItem_contact" onMouseOver="backgroundOn('sideItem_contact')" onMouseOut="backgroundOff('sideItem_contact')">
contact us
</DIV>
</A>
</div>
</div>
</font>
</div>
</body>
</html>
by either removing the lines noted below, OR removing all of the attributes from the .sideBar style, the hilighting works properly. I DON'T GET IT!!! again, this works perfectly in opera and firefox.
<!-- remove this line - <div class="sideBar"> -->
<div id="sideMenu" class="bgDark">
<div id="sideHeader"><STRONG>Home</STRONG></div>
<A id="sideLink" HREF="?section=home&page=news">
<DIV class="sideItem" id="sideItem_news" onMouseOver="backgroundOn('sideItem_news')" onMouseOut="backgroundOff('sideItem_news')">
news
</DIV>
</A>
<A id="sideLink" HREF="?section=home&page=policies">
<DIV class="sideItem" id="sideItem_policies" onMouseOver="backgroundOn('sideItem_policies')" onMouseOut="backgroundOff('sideItem_policies')">
policies
</DIV>
</A>
<A id="sideLink" HREF="?section=home&page=policies#rights">
<DIV class="sideItem" id="sideItem_rights" onMouseOver="backgroundOn('sideItem_rights')" onMouseOut="backgroundOff('sideItem_rights')">
student's rights
</DIV>
</A>
<A id="sideLink" HREF="?section=about&page=contact">
<DIV class="sideItem" id="sideItem_contact" onMouseOver="backgroundOn('sideItem_contact')" onMouseOut="backgroundOff('sideItem_contact')">
contact us
</DIV>
</A>
</div>
<!-- remove this line - </div> -->
