summaryrefslogtreecommitdiff
path: root/examples/qmlapp/index.html
blob: a000d52f656c4e9d0abf1b5502456bfc0ae53927 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<html>
    <head>
        <script>
            document.write('<script src="' + (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/]+)/.exec(location.search)[1]) + '/webchannel.js/createWebChannel"><' + '/script>');
            function output(x)
            {
                document.querySelector("#out").innerHTML += x + "<br/>";
            }
        </script>
        <script>
            window.onload = function() {
                createWebChannel(function(c) {
                    c.subscribe(
                        "foobar",
                        function(message) {
                            output(message);
                        }
                    );
                    c.exec(
                        {a:"This is a request from HTML"},
                        function(response) {
                            output(response.b);
                        }
                    );
                });
            };
        </script>
    </head>
    <body>
    <a href="javascript:send()">Go</a>
    <div id="out"></div>
    </body>
</html>