是否可以使用Javascript在Firefox,Safari和Chrome中阅读剪贴板? [英] Is it possible to read the clipboard in Firefox, Safari and Chrome using Javascript?
本文介绍了是否可以使用Javascript在Firefox,Safari和Chrome中阅读剪贴板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用Javascript阅读剪贴板的内容。使用Internet Explorer可以使用
window.clipdData.getData(Text)
在Firefox,Safari和Chrome中有类似的阅读剪贴板的方法吗?
解决方案Safari支持在
onpaste
事件期间阅读剪贴板:
您要执行的操作如下:
someDomNode.onpaste = function(e){
var paste = e.clipboardData&& e.clipboardData.getData?
e.clipboardData.getData('text / plain')://标准
window.clipboardData&& window.clipboardData.getData?
window.clipboardData.getData('Text'):// MS
false;
if(paste){
// ...
}
};
I'm trying to read the contents of the clipboard using Javascript. With Internet Explorer it's possible using
window.clipdData.getData("Text")
Is there a similar way of reading the clipboard in Firefox, Safari and Chrome?
解决方案Safari supports reading the clipboard during
onpaste
events:You want to do something like:
someDomNode.onpaste = function(e) { var paste = e.clipboardData && e.clipboardData.getData ? e.clipboardData.getData('text/plain') : // Standard window.clipboardData && window.clipboardData.getData ? window.clipboardData.getData('Text') : // MS false; if(paste) { // ... } };
这篇关于是否可以使用Javascript在Firefox,Safari和Chrome中阅读剪贴板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文