vnc_auto.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!--
  2. noVNC Example: Automatically connect on page load.
  3. Connect parameters are provided in query string:
  4. http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
  5. -->
  6. <html>
  7. <head>
  8. <title>VNC Client</title>
  9. <link rel="stylesheet" href="include/plain.css" TITLE="plain">
  10. <link rel="Alternate StyleSheet" href="include/black.css" TITLE="Black">
  11. <!--
  12. <script type='text/javascript'
  13. src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
  14. -->
  15. <script src="include/vnc.js"></script>
  16. </head>
  17. <body style="margin: 0px;">
  18. <div id="VNC_screen">
  19. <div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;">
  20. <table border=0 width=100%><tr>
  21. <td><div id="VNC_status">Loading</div></td>
  22. <td width=1%><div id="VNC_buttons">
  23. <input type=button value="Send CtrlAltDel"
  24. id="sendCtrlAltDelButton"
  25. onclick="sendCtrlAltDel();"></div></td>
  26. </tr></table>
  27. </div>
  28. <canvas id="VNC_canvas" width="640px" height="20px">
  29. Canvas not supported.
  30. </canvas>
  31. </div>
  32. </body>
  33. <script>
  34. function setPassword() {
  35. RFB.sendPassword($('password_input').value);
  36. return false;
  37. }
  38. function sendCtrlAltDel() {
  39. RFB.sendCtrlAltDel();
  40. }
  41. function updateState(state, msg) {
  42. var s, sb, klass, html;
  43. s = $('VNC_status');
  44. sb = $('VNC_status_bar');
  45. cad = $('sendCtrlAltDelButton');
  46. switch (state) {
  47. case 'failed':
  48. case 'fatal':
  49. klass = "VNC_status_error";
  50. break;
  51. case 'normal':
  52. klass = "VNC_status_normal";
  53. break;
  54. case 'disconnected':
  55. case 'loaded':
  56. klass = "VNC_status_normal";
  57. break;
  58. case 'password':
  59. msg = '<form onsubmit="return setPassword();"';
  60. msg += ' style="margin-bottom: 0px">';
  61. msg += 'Password Required: ';
  62. msg += '<input type=password size=10 id="password_input" class="VNC_status">';
  63. msg += '</form>';
  64. // Fall through
  65. default:
  66. klass = "VNC_status_warn";
  67. }
  68. if (state === "normal") { cad.disabled = false; }
  69. else { cad.disabled = true; }
  70. if (typeof(msg) !== 'undefined') {
  71. sb.setAttribute("class", klass);
  72. s.innerHTML = msg;
  73. }
  74. }
  75. window.onload = function () {
  76. var host, port, password;
  77. url = document.location.href;
  78. host = (url.match(/host=([A-Za-z0-9.\-]*)/) || ['',''])[1];
  79. port = (url.match(/port=([0-9]*)/) || ['',''])[1];
  80. password = (url.match(/password=([^&#]*)/) || ['',''])[1];
  81. if ((!host) || (!port)) {
  82. updateState('failed',
  83. "Must specify host and port in URL");
  84. return;
  85. }
  86. RFB.setEncrypt((url.match(/encrypt=([A-Za-z0-9]*)/) || ['',1])[1]);
  87. RFB.setBase64((url.match(/base64=([A-Za-z0-9]*)/) || ['',1])[1]);
  88. RFB.setTrueColor((url.match(/true_color=([A-Za-z0-9]*)/) || ['',1])[1]);
  89. RFB.setCursor((url.match(/cursor=([A-Za-z0-9]*)/) || ['',true])[1]);
  90. RFB.setUpdateState(updateState);
  91. RFB.load();
  92. RFB.connect(host, port, password);
  93. }
  94. </script>
  95. </html>