iam not understanding how to copy to clickboard as soon as I click on a textarea..I mean it should select all content inside it and then it should pop and and ask something like 'press ctrl c' to copy into clipboard..
I already have a code BUT unable to select full text in text area and should copy into clipboard..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function myfunc2() {
var selectedobj=document.getElementById('showthis');
if(selectedobj.className=='hide'){ //check if classname is hide
selectedobj.style.display = "block";
selectedobj.readOnly=true;
selectedobj.className ='show';
}else{
selectedobj.style.display = "none";
selectedobj.className ='hide';
}
}
function copyToClipboard (text) {
window.prompt ("Copy to clipboard: Ctrl+C, Enter", text);
}
function select_all()
{
// alert(document.getElementById("showthis").value);
var text_val=eval("document.getElementById('showthis').value");
text_val.focus();
var copy = text_val.select();
window.prompt ("Copy to clipboard: Ctrl+C, Enter", copy);
}
</script>
</head>
<body>
<label onclick="myfunc2()">Click here</label>
<textarea id="showthis" style="display:none" class="hide" onclick="select_all()" readonly>dfdsfsfasdfdsfsfasdfssdfsfasf</textarea>
</body>
</html>
could anyone pls look into this...
EDITED: I need only Javascript code (not JQuery)