Information Technology Reference
In-Depth Information
Listing 6-2. Javascript User Detection Code
<script type="text/javascript">
var ua = navigator.userAgent.toLowerCase();
window.onload = function() {
if(navigator.userAgent.match(/android/i)) {
alert('Android Rocks!');
}
else {
alert('Yawn, I guess your boring Desktop browser is okay');
}
}
</script>
Figure 6-5. Alert dialog box on the Android 2.3 Gingerbread device
Figure 6-6. Boring alert dialog box on Google's Chrome web browser
 
Search WWH ::




Custom Search