Introduction:
Article explains how to copy the text values into clipboard using javascript.
Main:
For copying to clipboard normally we using the below DOM,
rng.execCommand(“Copy”);
Code:
function copycode(id){
//copyToClipboard(document.getElementById(id).value);
copy(document.getElementById(id).value);
}
function copycode(obj) {
obj = document.getElementById(obj);
if(is_ie && obj.style.display != 'none') {
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
}
function copycode(id){ //copyToClipboard(document.getElementById(id).value); copy(document.getElementById(id).value); } function copycode(obj) { obj = document.getElementById(obj); if(is_ie && obj.style.display != 'none') { var rng = document.body.createTextRange(); rng.moveToElementText(obj); rng.scrollIntoView(); rng.select(); rng.execCommand("Copy"); rng.collapse(false); } } |
Conclusion:
Hope this helps,
Happy Coding.
I agree with much of what peoples comments are that I am reading here.