Revision control
+ <!DOCTYPE html>
<html>
<head>
- <script>
- document.write('<script src="' + (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/]+)/.exec(location.search)[1]) + '/webchannel.js/createWebChannel"><' + '/script>');
+ <script type="text/javascript" src="qrc:///qwebchannel/webchannel.js"></script>
+ <script type="text/javascript">
function output(x)
{
document.querySelector("#out").innerHTML += x + "<br/>";
}
- </script>
- <script>
window.onload = function() {
- createWebChannel(function(c) {
+ var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/]+)/.exec(location.search)[1]);
+ new QWebChannel(baseUrl, function(c) {
c.subscribe(
"foobar",
function(message) {
output(message);
}
);
window.send = function() {
c.exec(
- JSON.stringify({a:"This is a request from HTML"}),
+ {a:"This is a request from HTML"},
function(response) {
- output(JSON.parse(response).b);
+ output(response.b);
}
);
};
window.send();
});
};
</script>
</head>
<body>
<a href="javascript:send()">Go</a>
<div id="out"></div>
</body>
</html>