Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-08-25 07:33:24
Point:500 Replies:11 POST_ID:828755USER_ID:11059
Topic:
JavaScript;jQuery;Hypertext Markup Language (HTML)
Just want to select all text in following code with div contenteditable tag and do copy and then paste it in the same div tag corresponding to the current cursor postion.
Some one told us me to use exexcCommand for copy and paster for Chrome that
will be easy and fast, I tried it before, Whatever I specifiy such as
document.getElementById('divtxt).execCommand("Paste") that is not working
even I set document.execCommand("Paste") not working either
Any hint provide me what I am doing wrong for the attached code
Please advise
Duncan
Some one told us me to use exexcCommand for copy and paster for Chrome that
will be easy and fast, I tried it before, Whatever I specifiy such as
document.getElementById('divtxt).execCommand("Paste") that is not working
even I set document.execCommand("Paste") not working either
Any hint provide me what I am doing wrong for the attached code
Please advise
Duncan
<html ><head><style type="text/css">.editor{width:605px;border:0px; none;display:block;position:relative}.editor .divtxt{width:605px;height:250px;background:0;border:0;border-width:0 1px 1px 1px;border-style:solid;border-color:#d7d7d7}.divtxt p{display:inline;border:0px;margin:0px;padding;0px;font-size:16px;font-weight:0;word-spacing:-6;font-family:Courier New ;}</style><script type="text/javascript">function CopyToClipboard(tagid, text ){ copyDiv.unselectable = "off"; document.getElementById(tagid).focus(); document.execCommand('SelectAll'); document.execCommand("Copy", false, null); }function PasteFromClipboard(tagid){ document.execCommand("Paste");}</script></head><body ><div class="editor" ><div class="divtxt" contenteditable="true" style="border-width:1px;border-color:#c0c0c0" id="divtxt" ><p>How to solve the question</p></div></div><button onclick="CopyToClipboard('divtxt','How to paste in the div tag');">Copy</button><button onclick="PasteFromClipboard(this);">Paste</button></body></html> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:
Author: duncanb7 replied at 2024-08-30 21:11:42
Thanks for all of your reply, I would like to continue this topic
in new thread
Thanks
Duncan
in new thread
Thanks
Duncan
Accepted Solution
Expert: skullnobrains replied at 2024-08-28 02:13:01
125 points EXCELLENT
it should work with rich text unless jquery does something or the bug described here applies to you : http://support.microsoft.com/kb/826008/en-us, or you paste to some place that does not handle rich text
but anyway, even the flash version is likely not to work without extra hacks if at all in a near future. i guess activeX will keep working (on IE) but prompt about security issues like it already does.no idea about java but something similar will happen.
re-reading your question, if you just want to move text contained in one location to the div under the cursor, you don't need the clipboard. just detect the div that is currently hovered and move the text in plain regular js.
if you give a description of what you really want to achieve, it is more than likely we can devise something that does not require unreliable clipboard access. if you have access to both the copy and paste sides, it is also very easy to emulate a dumb clipboard in js, and there should be codes around that do it. if you need it to work across multiple windows, you can for example clip the data in a cookie (2 lines on each side)
but anyway, even the flash version is likely not to work without extra hacks if at all in a near future. i guess activeX will keep working (on IE) but prompt about security issues like it already does.no idea about java but something similar will happen.
re-reading your question, if you just want to move text contained in one location to the div under the cursor, you don't need the clipboard. just detect the div that is currently hovered and move the text in plain regular js.
if you give a description of what you really want to achieve, it is more than likely we can devise something that does not require unreliable clipboard access. if you have access to both the copy and paste sides, it is also very easy to emulate a dumb clipboard in js, and there should be codes around that do it. if you need it to work across multiple windows, you can for example clip the data in a cookie (2 lines on each side)
Assisted Solution
Expert: Rob Jurd replied at 2024-08-26 20:39:11
125 points EXCELLENT
using Jquery with flash doesn't need to set google permission in javascript for clipboard security
that's because it's flash that is accessing the clipboard, not javascript.
Author: duncanb7 replied at 2024-08-26 04:59:44
using Jquery with flash doesn't need to set google permission in javascript for clipboard security
http://www.jquery4u.com/plugins/jquery-copy-clipboard-4-options/
http://www.steamdev.com/zclip/
but those jquery kid can not copy the text with bold,italic,understand that were made before copy, since after copy, the text became in plain text and all ,<b>,<u>,<i> is deleted or not included
http://www.jquery4u.com/plugins/jquery-copy-clipboard-4-options/
http://www.steamdev.com/zclip/
but those jquery kid can not copy the text with bold,italic,understand that were made before copy, since after copy, the text became in plain text and all ,<b>,<u>,<i> is deleted or not included
Expert: Rob Jurd replied at 2024-08-26 04:38:39
I agree, there's got to be a purpose and target audience, as has been stated. java applets and ActiveX are alternatives. They're all plugins that are given permission to run outside the security sandbox
Expert: skullnobrains replied at 2024-08-25 23:41:34
basically, your code is close, but you need to understand that most browsers will not allow you to programaticaly access the clipboard for obvious security reasons. if you do not target a specific bunch of users using a specific browser you have complete control over, my advice is just forget it.
maybe if you explain why you would want to do that, we can advice better ways of doing things.
if you're really interested in more generic alternatives, you'll find methods involving flash all over the internet
maybe if you explain why you would want to do that, we can advice better ways of doing things.
if you're really interested in more generic alternatives, you'll find methods involving flash all over the internet
Author: duncanb7 replied at 2024-08-25 21:51:54
so in other words, we need to do javascript code for copy and paste by ourselve
do you have other method to do that ?
do you have other method to do that ?
Assisted Solution
Expert: Rob Jurd replied at 2024-08-25 21:01:21
125 points EXCELLENT
I'm not sure it's supported in Chrome: http://help.dottoro.com/larpvnhw.php. You can see that chrome is grayed out for both copy and paste.
Assisted Solution
Expert: skullnobrains replied at 2024-08-25 10:21:11
125 points EXCELLENT
execCommand() is only usable for documents that have designmode activated from what i read in the manual. google for it, you'll have plenty of explanations and working examples in w3shools, the mozilla docs, msdn, ...
i'm sorry but i do not have enough time right now to play with your code. anyway this is obviously test code just to learn how to use the feature so it won't do any good unless you do the writing
i'm sorry but i do not have enough time right now to play with your code. anyway this is obviously test code just to learn how to use the feature so it won't do any good unless you do the writing
Author: duncanb7 replied at 2024-08-25 10:09:18
what is that, please make it clear
You know what I am asking for
Duncan
You know what I am asking for
Duncan
Expert: skullnobrains replied at 2024-08-25 10:02:27
you're mising document.designMode = "on";