|
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta charset="utf-8" />
- </head>
- <body>
- <input type="button" value="登录" onclick="testLogin()" />
- </body>
- </html>
- <script type="text/javascript" src="http://61.191.27.18:8081/js/jsw.js"></script>
- <script type="text/javascript">
- window.onload = function () {
- jSW.swInit({
- url: 'http://61.191.27.18:8081', // bv_nginx.exe服务器地址
- calltype: jSW.CallProtoType.AUTO, // AUTO: IE优先使用OCX, 如果希望IE仍然使用HTTP通信, 请使用jSW.CallProtoType.HTTP
- oninit: function(rc) {
- console.log('初始化:' + rc);
- }
- });
- }
- window.onbeforeunload = function () {
- jSW.swDeInit();
- }
- var session = null;
- function testLogin() {
- if (session) { delete session; }
- session = new jSW.SWSession({
- server: '127.0.0.1', // 如果是jSW.CallProtoType.OCX方式,这里需要填写具体的IP
- port: 9701,
- onopen: function (sess) {
- sess.swLogin({
- user: 'root',
- password: 'besovideo88',
- });
- },
- onclose: function (sess, evt) {
- console.error('连接服务器失败');
- }
- });
- // 注册事件的回调函数
- session.swAddCallBack('login', function (sender, event, json) {
- console.log(json.code)
- // console.log(JSON.stringify(json, null, 4))
- });
- }
- </script>
copycode |
|