summaryrefslogtreecommitdiff
path: root/examples/qmlapp/index.html
blob: d84d549b48b57e805bcf60d56b9265994d019e4e (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
34
35
36
37
38
39
40
41
42
<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>');
            function output(x)
            {
                document.querySelector("#out").innerHTML += x + "<br/>";
            }
        </script>
        <script>
            window.onload = function() {
                navigator.createWebChannel(function(c) {
                    c.subscribe(
                        "incoming-call",
                        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>