Revision control

<html>
<head>
<script>
function getWebChannelBaseUrl() {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == "webChannelBaseUrl")
return pair[1];
}
}
document.write('<script src="' + getWebChannelBaseUrl() + '"><' + '/script>');
window.onload = function() {
var textArea = document.querySelector("textarea");
function output(x) {
textArea.value = textArea.value + x + "\n";
}
navigator.webChannel.subscribe(
"incoming-call",
function(message) {
output(message);
}
);
- navigator.webChannel.execute(
+ };
+
+ function output(x)
+ {
+ document.querySelector("#out").innerHTML = x;
+ }
+
+ function send()
+ {
+ navigator.webChannel.exec(
{a:"This is a request from HTML"},
function(response) {
output(response.b);
}
);
- };
+ }
</script>
</head>
<body>
- <textarea style="width: 100%; height: 100%"></textarea>
+ <a href="javascript:send()">Go</a>
+ <div id="out"></div>
</body>
</html>