Link to home
Start Free TrialLog in
Avatar of ChloesDad
ChloesDadFlag for United Kingdom of Great Britain and Northern Ireland

asked on

What does this javascript function do

I have taken over a website, and I can work out what most things do, but this script is on almost every page and I can't work out what its doing. I can remove it and the page seems to work fine so some advice on its function would be brilliant.

<!-- #BeginEditable "style" -->
<script type="text/javascript"><!--//--><![CDATA[//><!--
sfHover = function() {
	var sfEls = document.getElementById("nav4").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>
<!-- #EndEditable -->

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Carl Dula
Carl Dula
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ChloesDad

ASKER

We do have dropdown menus on the site, but they appear to be functioning perfectly without this code.

I have found code in out common css that sets up the hover, the article mentions that IE doesn't support this, but I am testing on IE11, Is it only earlier versions of IE that didn't support this and hence need the JavaScript code?
Chances are you are correct about the earlier versions. If the code you are looking at is years old, then it makes that even more likely, since IE has had significant changes over the past several years.
Thanks, it is quite old. Either way, I can put the function into our PageHeader file which is included on every page, rather than having it directly on every page.