Simple demo of RemoteAndroid callback JavaScript

Copy this HTML source and save it to a file. Make the changes as marked.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Simple demo of RemoteAndroid callback JavaScript</title>
<script type="text/javascript">
//<![CDATA[
var loc;
function callback(o) {
    loc = o;
}
function load() {
    if(!loc || !loc.location) return;
    for(var i=0; i<loc.location.length; i++) {
        var d = document.getElementById(loc.location[i].name);
        if(d) {
            var detail = loc.location[i].detail;
            var s= ' none';
            if(detail) {
                var s = ' lat:' + detail.latitude +
                        ' lon:' + detail.longitude;
                if(detail.geo) {
                    s += ' addr:' + detail.geo.address[0];
                }
            }
            d.innerHTML = s;
        }
    }
}
//]]>
</script>

<!--
        replace this with your own domain
-->
<script type="text/javascript" src="http://your-hostname-at-dot-dyndns.org:8000/remand?callback=callback&location=1&geo=1"></script>

</head>
<body onload="load();">

<p>This page shows a simple demo of using a RemoteAndroid callback.</p>
<div>The current location will be shown here:</div>
<div>GPS location:<span id="gps"></span></div>
<div>Wireless location:<span id="network"></span></div>

</body>
</html>
Back