|
-
Aug 7th, 2002, 11:07 AM
#1
Thread Starter
Hyperactive Member
Copy & Paste
Is there javascript code to copy text inside textarea until I can paste it in any place
-
Aug 9th, 2002, 09:58 AM
#2
Hyperactive Member
this might give you ideas
Code:
<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>
i tested this only in IE6
of course coords must me numberic only
i didn't validate anything
bsw2112
-
Aug 9th, 2002, 10:18 AM
#3
Thread Starter
Hyperactive Member
I do not mean that
I mean copy text to paste it in any other programs .. for example to paste it in NotePad program.
-
Aug 9th, 2002, 10:36 AM
#4
Hyperactive Member
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
-
Aug 9th, 2002, 10:41 AM
#5
Thread Starter
Hyperactive Member
Copy
I mean copy to memory not to files in server.
-
Aug 9th, 2002, 12:03 PM
#6
Lively Member
he wants a function to highlight and copy text to the clip board through javascript.
Just Imagine what you can do with the power of php.
257 Tutorials and counting.
529 Snippets and growing.
Add yours today @
SnippetLibrary.com
-
Aug 9th, 2002, 12:38 PM
#7
Black Cat
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.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Aug 9th, 2002, 01:25 PM
#8
Thread Starter
Hyperactive Member
Yes
Yes or With Java or VBScript or PHP or ...........
-
Aug 10th, 2002, 06:22 AM
#9
New Member
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>
____________________________________________________
Any Problem made by man is solved by man.
-
Aug 10th, 2002, 06:52 AM
#10
Thread Starter
Hyperactive Member
Thanks M.R Abou_ghazi
Thank you too much . Relly very nice code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|