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=
10%
><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() {
44 function updateState(state, msg) {
45 var s, sb, klass, html;
47 sb = $('VNC_status_bar');
48 cad = $('sendCtrlAltDelButton');
52 klass =
"VNC_status_error";
55 klass =
"VNC_status_normal";
59 klass =
"VNC_status_normal";
62 msg = '
<form onsubmit=
"return setPassword();"';
63 msg += '
style=
"margin-bottom: 0px">';
64 msg += 'Password Required: ';
65 msg += '
<input type=password size=
10 id=
"password_input" class=
"VNC_status">';
69 klass =
"VNC_status_warn";
72 if (state ===
"normal") { cad.disabled = false; }
73 else { cad.disabled = true; }
75 if (typeof(msg) !== 'undefined') {
76 sb.setAttribute(
"class", klass);
81 window.onload = function () {
82 var host, port, password, encrypt;
84 url = document.location.href;
85 host = (url.match(/host=([A-Za-z0-
9.\-]*)/) || ['',''])[
1];
86 port = (url.match(/port=([
0-
9]*)/) || ['',''])[
1];
87 password = (url.match(/password=([^&#]*)/) || ['',''])[
1];
88 encrypt = (url.match(/encrypt=([A-Za-z0-
9]*)/) || ['',
1])[
1];
89 true_color = (url.match(/true_color=([A-Za-z0-
9]*)/) || ['',
1])[
1];
90 if ((!host) || (!port)) {
92 "Must specify host and port in URL");
96 RFB.setUpdateState(updateState);
98 RFB.connect(host, port, password, encrypt, true_color);