Change Class Attribute in Firefox and IE
Firefox and IE act differently when change class attribute. I used below codes to do this:
<SCRIPT LANGUAGE=”JavaScript”>
function locateHome() {
curUrl=location.href;
homeUrl=”<?php bloginfo(‘url’)?>/”;
homeEnUrl=”<?php bloginfo(‘url’)?>/?lang=en”;
homeZhUrl=”<?php bloginfo(‘url’)?>/?lang=zh”;
if(navigator.userAgent.indexOf(“MSIE”)>0) {
if ((curUrl==homeUrl) || (curUrl==homeEnUrl) || (curUrl==homeZhUrl)){
homeClass=nav.getElementsByTagName(“li”)[0].getAttribute(‘className’);
homeClass=homeClass+” current_page_item”;
nav.getElementsByTagName(“li”)[0].setAttribute(‘className’,homeClass);
}
}else {
if ((curUrl==homeUrl) || (curUrl==homeEnUrl) || (curUrl==homeZhUrl)){
homeClass=document.getElementById(“nav”).getElementsByTagName(“li”)[0].getAttribute(“class”);
homeClass=homeClass+” current_page_item”; //alert(“2″+homeClass);
document.getElementById(“nav”).getElementsByTagName(“li”)[0].setAttribute(“class”,homeClass);
}
}
locateHome();
</SCRIPT>