2 noVNC Example: Automatically connect on page load.
4 Connect parameters are provided in query string:
5 http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
9 <title>VNC Client
</title>
10 <link rel=
"stylesheet" href=
"include/plain.css" TITLE=
"plain">
11 <link rel=
"Alternate StyleSheet" href=
"include/black.css" TITLE=
"Black">
13 <script type='text/javascript'
14 src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
16 <script src=
"include/vnc.js"></script>
19 <body style=
"margin: 0px;">
21 <div id=
"VNC_status_bar" class=
"VNC_status_bar" style=
"margin-top: 0px;">
22 <table border=
0 width=
100%
><tr>
23 <td><div id=
"VNC_status">Loading
</div></td>
24 <td width=
1%
><div id=
"VNC_buttons">
25 <input type=button
value=
"Send CtrlAltDel"
26 id=
"sendCtrlAltDelButton"
27 onclick=
"sendCtrlAltDel();"></div></td>
30 <canvas id=
"VNC_canvas" width=
"640px" height=
"20px">
37 function setPassword() {
38 RFB.sendPassword($('password_input').value);
41 function sendCtrlAltDel() {
45 function updateState(state, msg) {
46 var s, sb, klass, html;
48 sb = $('VNC_status_bar');
49 cad = $('sendCtrlAltDelButton');
53 klass =
"VNC_status_error";
56 klass =
"VNC_status_normal";
60 klass =
"VNC_status_normal";
63 msg = '
<form onsubmit=
"return setPassword();"';
64 msg += '
style=
"margin-bottom: 0px">';
65 msg += 'Password Required: ';
66 msg += '
<input type=password size=
10 id=
"password_input" class=
"VNC_status">';
70 klass =
"VNC_status_warn";
73 if (state ===
"normal") { cad.disabled = false; }
74 else { cad.disabled = true; }
76 if (typeof(msg) !== 'undefined') {
77 sb.setAttribute(
"class", klass);
82 window.onload = function () {
83 var host, port, password;
85 host = Util.getQueryVar('host', null);
86 port = Util.getQueryVar('port', null);
87 password = Util.getQueryVar('password', '');
88 if ((!host) || (!port)) {
90 "Must specify host and port in URL");
94 RFB.setEncrypt(Util.getQueryVar('encrypt', true));
95 RFB.setBase64(Util.getQueryVar('base64', true));
96 RFB.setTrueColor(Util.getQueryVar('true_color', true));
97 RFB.setCursor(Util.getQueryVar('cursor', true));
98 RFB.setUpdateState(updateState);
101 RFB.connect(host, port, password);