Revision control
- <!DOCTYPE html>
- <html>
- <head>
- <script type="text/javascript" src="qrc:///qwebchannel/qwebchannel.js"></script>
- <script type="text/javascript">
- function output(x)
- {
- document.querySelector("#out").innerHTML += x + "<br/>";
- }
- window.onload = function() {
- 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(
- {a:"This is a request from HTML"},
- function(response) {
- output(response.b);
- }
- );
- };
- window.send();
- }, true);
- };
- </script>
- </head>
- <body>
- <a href="javascript:send()">Go</a>
- <div id="out"></div>
- </body>
- </html>