summaryrefslogtreecommitdiff
path: root/examples/qmlapp/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qmlapp/index.html')
-rw-r--r--examples/qmlapp/index.html14
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/qmlapp/index.html b/examples/qmlapp/index.html
index f62a386..4f4593c 100644
--- a/examples/qmlapp/index.html
+++ b/examples/qmlapp/index.html
@@ -1,15 +1,15 @@
+<!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) {
@@ -18,9 +18,9 @@
);
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);
}
);
};