Pages

Access Clibboard using Javascript

In Internet Explorer we can access clipboard programatically, the same is not possible in Firefox browser. the security permission are more in firefox, so it will not allow a programatical access to the clipboard. but we can copy and paste contents in the form.
if we use code to do the pasting of data from external contents, we can get data using this way.
window.clipboardData.getData("Text")

By doing this way, we lose the format of the content we copied, to avoid this we have another way to do the same.
var range = document.selection.createRange();
range.execCommand("paste");

if we write code for paste this way, the format of the content we copied will be preserved while pasting. it also accepts the table format data.

No comments:

Post a Comment