最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to read clipboard data in cross browser? - Stack Overflow

programmeradmin3浏览0评论

Possible Duplicates:
Copy / Put text on the clipboard with FireFox, Safari and Chrome
How to Copy to Clipboard in JavaScript?

Hi ,

scenario: I copied some content (either from notepad or word) and want to paste it in my iframe. On before pasting i want to manipulate the clipboard content. In IE i can do it with window.clipboardData.getData("Text"); How to read the clipboard data in other browsers (FF/chrome and safari)

Possible Duplicates:
Copy / Put text on the clipboard with FireFox, Safari and Chrome
How to Copy to Clipboard in JavaScript?

Hi ,

scenario: I copied some content (either from notepad or word) and want to paste it in my iframe. On before pasting i want to manipulate the clipboard content. In IE i can do it with window.clipboardData.getData("Text"); How to read the clipboard data in other browsers (FF/chrome and safari)

Share Improve this question edited May 23, 2017 at 12:00 CommunityBot 11 silver badge asked Apr 5, 2011 at 11:52 JagadeshJagadesh 6,8078 gold badges30 silver badges30 bronze badges 3
  • 8 @David, @Crowder: Both those questions are undoubtedly similar to this one but both concern putting data onto the clipboard rather than reading data from it. – Tim Down Commented Apr 5, 2011 at 13:05
  • @David, @Crowder: It is a possible duplicate of this question though: stackoverflow.com/questions/233719/… – Tim Down Commented Apr 5, 2011 at 13:13
  • 3 Jesus christ SO needs to moderate the mods so badly. Neither of the questions this was marked as a dupe of are the same question at ALL. – B T Commented Jun 27, 2016 at 9:05
Add a comment  | 

2 Answers 2

Reset to default 7

You'll only be able to do this in most browsers when the user explicitly triggers a paste (for example, by using Ctrl-V or the edit or context menus).

In Firefox and Opera you'll need to use a hack, such as the one I outlined here: JavaScript get clipboard data on paste event (Cross browser).

In Internet Explorer, Safari and Chrome, you can access the clipboard directly during a paste using window.clipboardData in IE and the paste event's clipboardData property in WebKit. More information can be found on the Apple developer site.

Incase of Firefox

By default, JavaScript is not allowed to read or set your clipboard data for security and privacy reasons. This is because websites scripts can erase and replace what you currently have in your clipboard (data loss issue) and they can read whatever you have in your clipboard (security and privacy issue)

From Here

发布评论

评论列表(0)

  1. 暂无评论