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

LVL 15
ChloesDadAsked:
Who is Participating?
 
carlmdCommented:
It is used for dropdown menus.

Take a look at:

http://www.htmldog.com/articles/suckerfish/dropdowns/
0
 
ChloesDadAuthor Commented:
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?
0
 
carlmdCommented:
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.
0
 
ChloesDadAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.