User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 330,339 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,717 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 316 | Replies: 2
Reply
Join Date: May 2008
Posts: 2
Reputation: cariocgl is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cariocgl cariocgl is offline Offline
Newbie Poster

How to make these Javascript codes work in Firefox too

  #1  
7 Days Ago
------------PART ONE------------------

  1. if(navigator.appName == "Netscape"){
  2. xmlHttp = new XMLHttpRequest();
  3. xmlHttp.open("GET",xmlfile , false);
  4. xmlHttp.send(null);
  5. docObj = xmlHttp.responseXML;
  6. var objNodesname = docObj.getElementsByTagName("name");
  7. }else{
  8. var docObj = new ActiveXObject("MSXML.DOMDocument");
  9. docObj.load(xmlfile);
  10. var objNodesname = docObj.getElementsByTagName("name");
  11. }

------------PART TWO------------------

  1. for (i = 0 ; i < objNodesnames.length ; i++) {
  2. if(navigator.appName == "Netscape"){
  3. objcurrent=objNodesnames.item(i);
  4. myceltext=objcurrent.childNodes.item(0);
  5. currenttext=document.createTextNode(myceltext.data);
  6. lstring=currenttext.data;
  7. lstring=lstring.substr(4)
  8. lstringcode=lstring.substr(0,4)
  9.  
  10. }else{
  11. lstring=objNodesnames.item(i).text;
  12. lstringcode=lstring.substr(0,4);
  13. lstring=lstring.substr(4);
  14. }
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Posts: 4
Reputation: KenK is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
KenK KenK is offline Offline
Newbie Poster

Re: How to make these Javascript codes work in Firefox too

  #2  
7 Days Ago
Try something like this to replace the first code:
function getXHR()
{
	/*	Used to retrieve and XML HTTP Request object
		Output: an XMLHttpRequest object
	*/
	
	var XHR;
	
	// First determine user's browser
	if (window.XMLHttpRequest)	// Non-IE browser such as FireFox or Netscape
	{
		return new XMLHttpRequest();
	}
	else if (window.ActiveXObject)	// IE
	{
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		// Assume browser doesn't support AJAX technologies
	}
}

The second bit of code should work fine applying the same logic: don't check for the actual browser (especially Netscape) but check if the element your trying to use exists in the browser.
Reply With Quote  
Join Date: May 2008
Posts: 2
Reputation: cariocgl is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cariocgl cariocgl is offline Offline
Newbie Poster

Re: How to make these Javascript codes work in Firefox too

  #3  
6 Days Ago
Thanks! I'll try it out.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Marketplace (Sponsored Links)
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 9:16 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC