Is there javascript code to copy text inside textarea until I can paste it in any place
Printable View
Is there javascript code to copy text inside textarea until I can paste it in any place
this might give you ideas
i tested this only in IE6Code:<html>
<head>
<style>
#lay1 { position:absolute; top:-100px; left:-100px; visibility:hidden }
</style>
<script>
function placeIt(frm1) {
var obj;
obj=document.getElementById("lay1")
obj.style.visibility = "visible";
obj.style.left = frm1.x.value;
obj.style.top = frm1.y.value;
txt.innerText = frm.a.value
}
</script>
</head>
<body>
<form name="frm">
<textarea cols=20 rows=5 name = "a" ></textarea>
<br>
x coor <input type ="text" name = "x" size ="5"><br>
y coor <input type ="text" name = "y" size ="5"><br><br>
<input type = "button" onClick="placeIt(this.form)" value = "place">
</form>
<div id ="lay1"><p id = "txt"></p></div>
</body>
</html>
of course coords must me numberic only
i didn't validate anything
bsw2112
I mean copy text to paste it in any other programs .. for example to paste it in NotePad program.
i don't think it is possible
because you don't have the ability in javascript
to write to files
maybe windows script host (WSH) can do that but i am not sure..
you can do what you want using a server side language like perl or asp. those languages can access files
bsw2112
I mean copy to memory not to files in server.
he wants a function to highlight and copy text to the clip board through javascript.
I don't remember there being an official (clipbook is OS specific) or portable (you can do this with IE) way of doing it with javascript, but I believe you might want to try Java.
You can at least highlight a textarea using its DOM "select()" method.
Yes or With Java or VBScript or PHP or ...........
insert this code into the <head> section of your HTML code...
and have a nice day...
...best regards...!!
____________________________________________________
<script>
//Copytext to clipboard- by Gennero ([email protected])
//Submited to DynamicDrive.com
//Visit http://www.dynamicdrive.com for this script
bBool=false
var copiedtext=""
var tempstore=""
function initiatecopy() {
bBool=true;
}
function copyit() {
if (bBool) {
tempstore=copiedtext
document.execCommand("Copy")
copiedtext=window.clipboardData.getData("Text");
if (tempstore!=copiedtext) {
alert(copiedtext);
}
bBool=false;
}
}
document.onselectionchange = initiatecopy
document.onmouseup = copyit
</script>
____________________________________________________
Thank you too much . Relly very nice code.