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 375,222 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,229 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

How to make these Javascript codes work in Firefox too

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  
May 6th, 2008
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  
All times are GMT -4. The time now is 3:39 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC