Copy to clipboard in desktop weppage

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

text copy when i click button in desktop wep page, And then that copied text should be paste in anywhere(excel,notepad..etc) in desktop

Hi,

We do not have straight forward API's for clipboard functionality. Can you try with the below JavaScript function to copy to clipboard. You need to pass the text to function as input param which going to be copied.

function copyText(text){

function selectElementText(element) {

if (document.selection) {

var range = document.body.createTextRange();

range.moveToElementText(element);

range.select();

} else if (window.getSelection) {

var range = document.createRange();

range.selectNode(element);

window.getSelection().removeAllRanges();

window.getSelection().addRange(range);

}

}

var element = document.createElement('DIV');

element.textContent = text;

document.body.appendChild(element);

selectElementText(element);

document.execCommand('copy');

element.remove();

}