html调用远程桌面,Javascript调用MsRdpClient 完成Web调用远程桌面(CSDN手动迁移)

1

2

3

4

5

6

RDP

7

8 body {9 padding: 0;10 margin: 0;11 }12

13

14

15

16 //if ("条件") {17 //if (window.opener.SetRDPID) {//调用打开此页的父页面中的方法18 //window.opener.SetRDPID("123");19 //};20 //连接远程桌面的方法

21 function RdpConnect() {22 varuserName, Pwd, server, domain, port;23 userName = "administrator"; //用户名

24 server = "192.168.1.117"; //IP

25 port = 3389; //端口

26 domain = "myDomain"; //域

27 if (!MsRdpClient.Connected) {28 try{29 document.getElementById("connectArea").style.display = "block"; //显示远程桌面div

30 MsRdpClient.Server = server; //设置远程桌面IP地址

31 try{32 MsRdpClient.AdvancedSettings2.RedirectDrives = false;33 MsRdpClient.AdvancedSettings2.RedirectPrinters = false;34 MsRdpClient.AdvancedSettings2.RedirectPrinters = false;35 MsRdpClient.AdvancedSettings2.RedirectClipboard = true;36 MsRdpClient.AdvancedSettings2.RedirectSmartCards = false;37 } catch(ex) {38 };39

40

41 MsRdpClient.Domain = domain;//域

42 MsRdpClient.UserName =userName;43 //MsRdpClient.AdvancedSettings2.ClearTextpassword = Pwd;//密码

44 MsRdpClient.AdvancedSettings2.RDPPort = port; //端口

45 if (document.getElementById("ColorDepth").value == 1) {46 ColorDepth16();47 } else{48 ColorDepthDefault();49 };50 MsRdpClient.FullScreen = 1; //是否全屏 0否 1是

51 if (document.getElementById("Screen").value == 1) {52 Screen1();53 } else{54 ScreenDefault();55 };56 try{57 //如果不支持,继续下面操作

58 MsRdpClient.AdvancedSettings7.EnableCredSspSupport = true;59 MsRdpClient.AdvancedSettings5.AuthenticationLevel = 2;60 } catch(ex) {61 } finally{62 MsRdpClient.Connect(); //连接远程桌面

63 }64 } catch(ex) {65 alert("发生错误:" + ex.message + "请尝试刷新页面重新连接。");66 };67 } else{68 alert("已连接!");69 };70 };71 //var logoff = false;//存储是否正常注销72 //全屏

73 function FullScreen() {74 if(MsRdpClient.Connected) {75 MsRdpClient.FullScreen = 1;76 };77 };78 //1024*768

79 function ScreenDefault() {80 MsRdpClient.Width = 1024; //设置远程桌面 显示区域的宽和高

81 MsRdpClient.Height = 768;82 MsRdpClient.DesktopWidth = 1024; //设置 远程桌面的宽和高

83 MsRdpClient.DesktopHeight = 768;84 };85 //800*600

86 function Screen1() {87 MsRdpClient.Width = 800; //设置远程桌面 显示区域的宽和高

88 MsRdpClient.Height = 600;89 MsRdpClient.DesktopWidth = 800; //设置 远程桌面的宽和高

90 MsRdpClient.DesktopHeight = 600;91 };92 //色彩度,默认32位

93 function ColorDepthDefault() {94 MsRdpClient.ColorDepth = 32;95 };96 //色彩度16位

97 function ColorDepth16() {98 MsRdpClient.ColorDepth = 16;99 };100 function reSet() {101 document.getElementById("Screen").selectedIndex = 1;102 document.getElementById("ColorDepth").selectedIndex = 1;103 };104

105 //关闭当前页面

106 function closeWindow() {107 window.opener = null;108 window.open("", "_self");109 window.close();110 };111

112

113

114 分辨率:

115 800*600

116 1024*768

117

118 色彩度:

119 16位

120 32位

121

122

123

124

125

126

127

128

129

130

131

132 classid="CLSID:7584c670-2274-4efb-b00b-d6aaba6d3850"

133 codebase="msrdp.cab#version=5,2,3790,0" width="1024px" height="768px">

134

135

136

137

138 function MsRdpClient::OnDisconnected(disconnectCode) {139 document.getElementById("connectArea").style.display = "none";140 //正常注销,代码为2141 //if (disconnectCode != 2) {142 //if (logoff == false) {143 //alert("计算机处于断开状态,请根据提示完成后续步骤:\r\n(1)如果您操作已完成,请刷新页面重新连接并注销;\r\n(2)如果仍需操作,请刷新页面后继续,完毕后请注销。\r\n谢谢您的配合!");144 //} else {145 //alert("计算机已注销,如需使用,请刷新此页面。");146 //}147 //} else {148 //logoff = true;//记录注销状态149 // //关闭当前页面150 //};

151 closeWindow();152 }153

154

155

156

157

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值