clipboard copy

by toubia95

HTML

<!-- The text field -->
<input type="text" value="Hello World" id="myInput">
<input type="text" value="Hello World2" id="test" onclick="">
<textarea></textarea>

JavaScript

var copyInput = function(x) {
  var el = document.getElementById(x);
  el.onclick = function() {
    this.select();
    document.execCommand("copy");
  }
}
copyInput('myInput');
copyInput('test');

var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
        }
    }
};