我们如何用javascript从纸板上抹去图像,使之成为习惯丰富的文字编辑? (ctrl+c and ctrl+v or a snapshot).
是否有任何人使用Ajax丰富的文字编辑? 是否将图像从剪辑到Ajax RTE工作?
由于这个问题经常出现在谷歌搜索结果中,我要指出,今天在所有现代浏览器(2018年)中,至少在谷歌·
To help others, I ll leave the link here with the answer made by Nick Rattalack
// window.addEventListener( paste , ... or
document.onpaste = function(event){
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
console.log(JSON.stringify(items)); // will give you the mime types
for (index in items) {
var item = items[index];
if (item.kind === file ) {
var blob = item.getAsFile();
var reader = new FileReader();
reader.onload = function(event){
console.log(event.target.result)}; // data url!
reader.readAsDataURL(blob);
}
}
}
这一点现在肯定是有可能的。 我不敢肯定IE/Safari。
See at imgur.com, onpaste, and pastepad. 作为实例,见,载于。 Joel 在其博客上写得优良。
为记录起见,您需要用户就您的内容发布Ctrl+V,然后可以从event.clip板Data
读取
But it retrieve only text format or URL from clipboard.
clipboardData
is IE only, it works with character string and return null if we paste an image.
a 试验实例
<form>
<input type="text" id="context" onClick="paste();">
</form>
<script type="text/javascript">
function paste() {
var sRetrieveData = clipboardData.getData("Text");
document.getElementById( context ).value = sRetrieveData;
}
</script>
By default clipboard access is not enabled on firefox, explanation here. On the other way, execCommand() only process text values and is not Firefox compliant.
与其他人一样,在独立实体的法典工作是一种安全风险,任何地点都可以查阅你的记号。
影像相对URL最容易复制的办法是使用 j、窗户活性X粉碎、或drag和 drop。
不幸的是, 不可能从您的剪辑板上传承一个形象。
如果你照像Microsoft Word这样的台式镜像复制一幅镜像和一些文字,那么图像将变成一个破碎的参考资料(尽管比例将正确),文本将正确贴出(格式将丢失)。
唯一可能的事情是复制教育、科学和技术部内部的形象,并在教育、科学和技术部内部重印。
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...
I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph? The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.