Friday, June 8, 2007

Flash Lite detection through a xHTML WAP site


I have developed a way to detect if the end users phone is Flash Lite compatible with use of a simple javascript to determine the browser and OS of the phone. Based on this I determine if I should redirect to a page with a Flash lite game download. Cheers!




Here is the code:
<script type="text/javascript">
function detectBrowser(){
var browser=navigator.appName
var b_version=navigator.appVersion
var version=parseFloat(b_version)
if ((browser=="Microsoft Pocket InternetExplorer")) {
setTimeout("location.href = 'win.html';",4500);
}else {
setTimeout("location.href = 'palm.html';",4500);
}
}//end browser based redirect
</script> </head>
<body onload="detectBrowser()">
Detecting Browser:
<script type="text/javascript">
//this will display to the user before redirecing
var x = navigator
document.write("Name=" + x.appName)
document.write("Version=" + x.appVersion)
</script>

No comments: