ArcherWong博客
首页
博客
guacamole实现剪切复制
作者:ArcherWong
分类:guacamole
时间:2019-01-03 21:34:45
阅读:438
主要功能是实现把堡垒机的内容复制到浏览器端,把浏览器端的文本复制到堡垒机上。 借助一个中间的文本框,现将堡垒机内容复制到一个文本框,然后把文本框内容复制出来。或者将需要传递到堡垒机的内容先复制到文本框,然后在传递到堡垒机上。 ``` //监听堡垒机端往剪切板复制事件,然后写入文本框中 client.onclipboard = function(stream, mimetype){ if (/^text\//.exec(mimetype)) { var stringReader = new Guacamole.StringReader(stream); var json = ""; stringReader.ontext = function ontext(text) { json += text } stringReader.onend = function() { var clipboardElement = document.getElementById("clipboard"); clipboardElement.value = ''; clipboardElement.value = json; } } } //将内容传送到往堡垒机,data是获取到的文本框中的内容 function setClipboard(data) { var stream = client.createClipboardStream("text/plain"); var writer = new Guacamole.StringWriter(stream); for (var i=0; i<data.length; i += 4096){ writer.sendText(data.substring(i, i+4096)); } writer.sendEnd(); } ```
标签:
上一篇:
golang笔记---关联数组(map)
下一篇:
centos7.3配置guacamole
文章分类
css
elasticsearch
git
golang
guacamole
javascript
letsencrypt
linux
nginx
other
php
python
vue
web
阅读排行
golang笔记---关联数组(map)
letsencrypt证书-管理工具certbot
centos7.3配置guacamole
golang笔记---template模板语法
nginx笔记-proxy_cache缓存详解
友情链接
node文件
laravel-vue
ArcherWong的博客园