3 noVNC Example: Automatically connect on page load.
4 Copyright (C) 2010 Joel Martin
5 Licensed under LGPL-3 (see LICENSE.txt)
7 Connect parameters are provided in query string:
8 http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
11 <title>VNC Client
</title>
12 <link rel=
"stylesheet" href=
"include/plain.css" title=
"plain">
14 <script type='text/javascript'
15 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
17 <script src=
"include/vnc.js"></script>
20 <body style=
"margin: 0px;">
22 <div id=
"VNC_status_bar" class=
"VNC_status_bar" style=
"margin-top: 0px;">
23 <table border=
0 width=
"100%"><tr>
24 <td><div id=
"VNC_status">Loading
</div></td>
25 <td width=
"1%"><div id=
"VNC_buttons">
26 <input type=button
value=
"Send CtrlAltDel"
27 id=
"sendCtrlAltDelButton">
31 <canvas id=
"VNC_canvas" width=
"640px" height=
"20px">
37 /*jslint white: false */
38 /*global window, $, Util, RFB, */
43 function setPassword() {
44 rfb.sendPassword($('password_input').value);
47 function sendCtrlAltDel() {
51 function updateState(rfb, state, oldstate, msg) {
52 var s, sb, cad, klass;
54 sb = $('VNC_status_bar');
55 cad = $('sendCtrlAltDelButton');
59 klass =
"VNC_status_error";
62 klass =
"VNC_status_normal";
66 klass =
"VNC_status_normal";
69 msg = '
<form onsubmit=
"return setPassword();"';
70 msg += '
style=
"margin-bottom: 0px">';
71 msg += 'Password Required: ';
72 msg += '
<input type=password size=
10 id=
"password_input" class=
"VNC_status">';
74 klass =
"VNC_status_warn";
77 klass =
"VNC_status_warn";
80 if (state ===
"normal") { cad.disabled = false; }
81 else { cad.disabled = true; }
83 if (typeof(msg) !== 'undefined') {
84 sb.setAttribute(
"class", klass);
89 window.onload = function () {
90 var host, port, password;
92 $('sendCtrlAltDelButton').onclick = sendCtrlAltDel;
94 host = WebUtil.getQueryVar('host', null);
95 port = WebUtil.getQueryVar('port', null);
96 password = WebUtil.getQueryVar('password', '');
97 if ((!host) || (!port)) {
99 "Must specify host and port in URL");
103 rfb = new RFB({'encrypt': WebUtil.getQueryVar('encrypt', false),
104 'true_color': WebUtil.getQueryVar('true_color', true),
105 'local_cursor': WebUtil.getQueryVar('cursor', true),
106 'updateState': updateState});
107 rfb.connect(host, port, password);