JavaScript
HTML JavaScript CSS
Table of Contents

Copy to Clipboard

function copytoclip() {
       document.getElementById("terza").style.display = "block";
       selectText("terza");
       document.execCommand("Copy");
       document.getElementById("terza").style.display = "none";
}
 
function selectText(containerid) {
    if (document.selection) {
        var range = document.body.createTextRange();
        range.moveToElementText(document.getElementById(containerid));
        range.select();
    } else if (window.getSelection) {
        var range = document.createRange();
        range.selectNode(document.getElementById(containerid));
        window.getSelection().addRange(range);
    }
}
 
Es di codice chiamante: <input type="submit" value="Copy" onclick="copytoclip()">
**N.B.** Parametrizzare "terza"
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License