473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

contenteditable div and dataTransfer.getData available formats?

Hello every1,
I have a "<DIV" tag with contenteditable turned on. I am using this as
an area that users can either paste or drag/drop text into. The text
can come from other browser windows and of course can contain HTML.
Users will typically just click CTRL+A to select an entire web page and
then either copy/paste or drag/drop into this div. There's really no
code for all this other than specifying "contenteditable" in the div
Tag, and some other code I've added that will conditionally move these
contents to a hidden field so that my codebehind can get to it (i'm
using VB .net). This part works great EXCEPT when whatever the user
copies contains a "&ltFORM" tag. This will then cause my hidden field
in the codebehind to see a "blank" value inb the hidden field.
I tried simply removing or replacing the form tags once the contents
had been pasted/dropped, but this does not work. I did determine
however that if this replacement takes place BEFORE anything gets
dropped into the div, then my codebehind sees the value just fine.
This is where my attempt to use "dataTransfer.getData" comes into play.
It appears I can only specify 'text' or URL' as a parameter, which does
me no good since it strips out all the HTML. I'd like to be able to
specify something like dataTransfer.getData('HTML') so that I can do a
replace before allowing the contents to paste into the div.
1) Is this possible?.
2) If not, has anyone else come across the problem with the form tags,
and is there some other approach I might try?
target browser is I.E. 6.xxx
Thanks for any help.
The code below is just my experimenting but perhaps it may help:
(in this example I'm actually using a textbox instead of a hidden
field. Results are the same):
function UpdRichText(){
//replace any form tags with xform. needed so hRichText doesn't
return an empty string
var oDiv = document.getElementById('oDiv');
if(window.event.type == 'dragenter' || window.event.type ==
'beforepaste'){
alert(queryInterface(window.event.dataTransfer));
oDiv.innerHTML =
window.event.dataTransfer.getData('Text').replace(/\<form/gi,"<xform");
oDiv.innerHTML =
window.event.dataTransfer.getData('Text').replace(/\<\/form/gi,"</xform");
}
document.getElementById('xRichTextBox1_oTextarea') .value =
oDiv.innerHTML;
//window.event.dataTransfer.getData('Text')
}
<DIV id="oDiv" contentEditable=true
style="WIDTH: 300; HEIGHT: 300; BORDER-RIGHT: #99ccff inset;
PADDING-RIGHT: 3px; BORDER-TOP: #99ccff inset; PADDING-LEFT: 3px;
PADDING-BOTTOM: 3px; OVERFLOW: auto; BORDER-LEFT: #99ccff inset; COLOR:
black; PADDING-TOP: 3px; BORDER-BOTTOM: #99ccff inset;
SCROLLBAR-BASE-COLOR: #99ccff; BACKGROUND-COLOR: white;"
align=left ondragenter="UpdRichText();"
onbeforepaste="UpdRichText();"></DIV>
<asp:TextBox ID="oTextarea" Runat="server" Wrap="False"
TextMode="MultiLine" style="WIDTH: 300; HEIGHT: 300;OVERFLOW: auto;
DISPLAY: none;"></asp:TextBox>

Dec 7 '05 #1
3 3220
Anyone???

Dec 9 '05 #2
Not a single response!?!?!?!?!?!?

Dec 19 '05 #3
nAmYzArC said the following on 12/19/2005 1:48 PM:
Not a single response!?!?!?!?!?!?


Response to what?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: gboissiere | last post by:
Hello 'contentEditable' gurus, The example code below uses contentEditable to let the user edit the <div> element directly in their browser. Works also using designMode for the document. ...
2
by: José Joye | last post by:
I'm playing around with the "CallContext" class to pass around extra information between my client and Server applications (implemented with Remoting). My Server is a SAO-singlecall. If I try...
6
by: Andy | last post by:
I'm making a drag and drop application, and in the *_DragDrop(...)-method I have the following code: private void SelectTree_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) {...
2
by: Simon | last post by:
I have done a screen clipping in oneNote and now want to save to file. So I copy the image in oneNote, and then using c# try and getData from the clipboard and store in an image to be able to...
1
by: delraydog | last post by:
Does a contentEditable DIV have the notion of an internal document? I'm trying to convert code that uses an IFrame.contentWindow.document to use the "document" inside a contentEditable DIV but they...
4
by: dwhalen | last post by:
Hi Everyone. I'm new to drag-and-drop, and I'm running into a problem getting some code I found to work in FireFox. I have a third-party Tree control that accepts droppable items that implement...
5
by: nagar | last post by:
I have a .NET 2.0 application that needs to backup and restore the contents of the clipboard. When I back it up, I use this code: DataObject oldClipboard = Clipboard.GetDataObject();...
0
by: =?ISO-8859-1?Q?=22Ro=DFert_G=2E_Schaffrath=22?= | last post by:
Sorry for the cross-posting. I am having a hard time trying to classify exactly what group this question would apply to. I had posted an earlier message to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.