Jump to content

problems with FF6


Recommended Posts

This js code works in every browser EXCEPT Firefox. I was running FF5 and it didn't work, updated to FF6 and still doesn't work.Firebug returns the error "apps is not defined ..... if (element == apps) {"js

function change(element){var xmlhttp;if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.onreadystatechange=function()  {  if (xmlhttp.readyState==4 && xmlhttp.status==200)    {    document.getElementById("content").innerHTML=xmlhttp.responseText;    }  }  if (element == apps) {	xmlhttp.open("GET","xml/apps.xml",true);	xmlhttp.send();	}  else if (element == solutions) {  	xmlhttp.open("GET","xml/solutions.xml",true);	xmlhttp.send();  }  else if (element == about) {  	xmlhttp.open("GET","xml/about.xml",true);	xmlhttp.send();  }  else if (element == team) {  	xmlhttp.open("GET","xml/team.xml",true);	xmlhttp.send();  }  else if (element == labs) {  	xmlhttp.open("GET","xml/labs.xml",true);	xmlhttp.send();  }  else {  	xmlhttp.open("GET","xml/contact.xml",true);	xmlhttp.send();  }}


<table height="45px" width="860px" align="center" border="0" cellspacing="0" cellpadding="0" layout="fixed" z-index="1">	<tr>		<td width="60px"></td>		<td width="133px" align="center"><a href="#apps" onclick="change(this), set_active(this), navoff(this)" class="nav" id="apps">APPS</a></td>		<td width="160" align="center"><a href="#solutions" onclick="change(this), set_active(this), navoff(this)" class="nav" id="solutions">SOLUTIONS</a></td>		<td width="125px" align="center"><a href="#about" onclick="change(this), set_active(this), navoff(this)" class="nav" id="about">ABOUT</a></td>		<td width="117px" align="center"><a href="#team" onclick="change(this), set_active(this), navoff(this)" class="nav" id="team">TEAM</a></td>		<td width="131px" align="center"><a href="#labs" onclick="change(this), set_active(this), navoff(this)" class="nav" id="labs">LABS</a></td>		<td width="133px" align="center"><a href="#contact" onclick="change(this), set_active(this), navoff(this)" class="nav" id="contact">CONTACT</a></td>	</tr></table>

Link to comment
Share on other sites

are you sure that app's not supposed to be quoted? Also, it appears you are wanting to access the ID of the element, but you are just checking unquoted strings against the element itself (which is just a DOM element being passed into the function). I won't go in how to optimize your markup, but you could simplify your change function greatly.

function change(element){  var url = "xml/" + element.id + ".xml";  var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"));  xmlhttp.onreadystatechange=function(){	if (xmlhttp.readyState==4 && xmlhttp.status==200){	  document.getElementById("content").innerHTML=xmlhttp.responseText;	};  };  xmlhttp.open("GET",url,true);  xmlhttp.send();};

Edited by thescientist
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...