Jump to content

problems with FF6


mwbarry

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();  }}

html

<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();};

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...