How to read clipboard data in cross browser?
Possible Duplicates:
Copy 开发者_如何学Go/ 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)
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
精彩评论