Skip to main content

3.2 – Using object or cookie for parameters

You can also use objects or cookie for parameters:

Object parameters with Rdp2:

window.onload = function() {
  var parameters = {
    gateway: '192.168.12.111',
    server: '192.168.12.117',
    user: 'vmuser',
    pwd: 'password'
  };
  var r = new svGlobal.Rdp2(parameters);
  r.addSurface(new svGlobal.LocalInterface());
  r.run();
};
window.onload = function() {
  document.cookie = 'gateway=192.168.12.111';
  document.cookie = 'server=192.168.12.117';
  document.cookie = 'user=vmuser';
  document.cookie = 'pwd=password';
  var r = new svGlobal.Rdp2();
  r.addSurface(new svGlobal.LocalInterface());
  r.run();
};

You can only set cookies if the web page is from http server.

HTTP Header parameters:

Following parameters can also be transferred within HTTP Headers:

gw_server, gw_port, gw_symlink, gw_user, gw_pwd

Best practices:

Don’t mix your web page with JavaScript code. You should always put your JavaScript code into external files because:

  • Content-Security-Policy HTTP header can block this kind of mixed content.
  • This is blocked by Chrome Web Store App.
  • You cannot “pretty print” your code in browser’s Developer Tool, which is helpful when the JavaScript code is minified.
  • You cannot dynamically modify your code in the Developer Tool, which is really helpful on debugging and verifying your fix.
  • It’s better to put the Canvas element in a DIV.
  • You can have multiple Canvas elements in one page (using iframe or DIV) for multiple remote connections.