Page 1 of 1

ajax browser check

Posted: Tue Jan 16, 2007 7:36 am
by pedroz

Code: Select all

<script language="javascript" type="text/javascript">
<!-- 
//Browser Support Code
function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
}
//-->
</script>
I found the code below to check if the browser supports Ajax [but it is javascript]

I would like to know if there is any PHP script doing the checking above and displaying a yes/no.

example:
Internet explorer 4.0
http:/myhost/check.php
output: ajax NOT supported

Internet explorer 7.0
http:/myhost/check.php
output: ajax supported

Thanks

Posted: Tue Jan 16, 2007 7:58 am
by CoderGoblin
get_browser... Don't forget to get an updated browscap.ini file. Link on the page

You would have to create your own list though.

Posted: Tue Jan 16, 2007 3:19 pm
by feyd
It should be noted that PHP has no way of telling (without additional help from the client itself) if Javascript is enabled. If you want to check the browser for Ajax availability, it really should be done with Javascript. No Javascript, no Ajax.