Jump to content

is something wrong with this code?


carinemaz

Recommended Posts

cause it's not working...

<script type="text/javascript">var rows = document.getElementsbytagname("tr");for (var i=0; i <rows.length; i++) {rows[i].onmouseover=function() {this.className += " hilite";}rows[i].onmouseout=function() {this.className=this.className.replace("hilite" , "");}}</script>

I'm trying to create a hover effect for IE6, in a table.When I apply the class .hilite to my tr tag, the row looks the way it should look when I hover over it... and when I do mouseover nothing happens...Any suggestions?Thanks

Link to comment
Share on other sites

no... unfortunatly, still not working...

This one will work :) head part:
<style type="text/css"><!--.hilite{background-color: #C0C0C0;color: inherit;}--></style><script type="text/javascript"><!--function getElements(){var rows = document.getElementsByTagName("tr"); for (var i = 0; i < rows.length; i++){  rows[i].onmouseover=function(){   this.className += "hilite";  }  rows[i].onmouseout = function(){   this.className=this.className.replace("hilite" , "");  }  }}//--></script>

and to the body:

<body onload="getElements()"><table summary=""><tr><td>tr 1</td></tr><tr><td>tr 2</td></tr></table>

or You can just set class attribute as: this.setAttribute('class', 'hilite'); and then remove it: this.removeAttribute('class');Works with Firefox, Opera and Epiphany, I have no MSIE but should work with it too.

Link to comment
Share on other sites

ok, I used your code, and it works on my localhost, but not on the website :) The table is actually being called by include() and the content is on my sql database... Not sure if it's creating some sort of conflit, or if I'm still doing something wrong... Anyhow it's driving me nuts....Here is the complet code, and the link : http://www.medipsy.com/medecin/medecin.php

<!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><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>MEDIPSY</title><link rel="stylesheet" type="text/css" href="medipsy_m.css" /><link rel="stylesheet" type="text/css" href="dropdownmenu_medipsy.css" /><style type="text/css">#body {width: 930px;}#main {width: 730px;float: right;}#sidebar {width: 140px;float: left;display: block;}table {border-collapse: collapse;}tr:hover, .hilite {background-color: #34339B;color:#FFF;}td {padding: 0 0 0 5px;width: 180px;border: 1px solid #34339B;}.tdentete {font-weight:bold;font-size: 20px;color: #34339B;}.tdtelephone {width: 120px;text-align: center;padding: 0;}.tdtitre {width: 100px;text-align: center;padding: 0;}</style><script type="text/javascript"><!--function getElements(){var rows = document.getElementsByTagName("tr");for (var i = 0; i < rows.length; i++){ rows[i].onmouseover=function(){  this.className += "hilite"; } rows[i].onmouseout = function(){  this.className=this.className.replace("hilite" , ""); } }}//--></script><script language="JavaScript"><!--function SymError(){  return true;}window.onerror = SymError;var SymRealWinOpen = window.open;function SymWinOpen(url, name, attributes){  return (new Object());}window.open = SymWinOpen;//--></script><script type="text/javascript"><!--//--><![CDATA[//><!--sfHover = function() {	var sfEls = document.getElementById("nav").getElementsByTagName("LI");	for (var i=0; i<sfEls.length; i++) {		sfEls[i].onmouseover=function() {			this.className+=" sfhover";		}		sfEls[i].onmouseout=function() {			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");		}	}}if (window.attachEvent) window.attachEvent("onload", sfHover);//--><!]]></script></head><body onload="getElements()"><?php include('entete.inc')?><div id="body"><div id="main"><table><tr><td><span class="tdentete">Medecin</span></td><td><span class="tdentete">Clinique</span></td><td class="tdtelephone"><span class="tdentete">Téléphone</span></td><td class="tdtitre"><span class="tdentete">Type</span></td><td class="tdtitre"><span class="tdentete">Pst CME</span></td></tr></table><?phpinclude ('select_medecin.inc')?></div><div id="sidebar"><h3>Afficher la liste par :</h3><form action="#" method="post">Docteurs<input type="radio" checked="checked" onclick="window.location.href='medecin.php?typetri=1'" /><br/>Cliniques<input type="radio" onclick="window.location.href='medecin.php?typetri=2'" /></form></div>	<?phpinclude('pied2page.inc')?>	</div></body></html><script language="JavaScript"><!--var SymRealOnLoad;var SymRealOnUnload;function SymOnUnload(){  window.open = SymWinOpen;  if(SymRealOnUnload != null)     SymRealOnUnload();}function SymOnLoad(){  if(SymRealOnLoad != null)     SymRealOnLoad();  window.open = SymRealWinOpen;  SymRealOnUnload = window.onunload;  window.onunload = SymOnUnload;}SymRealOnLoad = window.onload;window.onload = SymOnLoad;//--></script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...