PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
pedroz
Forum Commoner
Posts: 99 Joined: Thu Nov 03, 2005 6:21 am
Post
by pedroz » Tue Jan 16, 2007 7:36 am
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
CoderGoblin
DevNet Resident
Posts: 1425 Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany
Post
by CoderGoblin » Tue Jan 16, 2007 7:58 am
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Jan 16, 2007 3:19 pm
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.