473,659 Members | 3,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

contenteditable div and dataTransfer.ge tData 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 "contenteditabl e" 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.g etData" 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.ge tData('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.getEle mentById('oDiv' );
if(window.event .type == 'dragenter' || window.event.ty pe ==
'beforepaste'){
alert(queryInte rface(window.ev ent.dataTransfe r));
oDiv.innerHTML =
window.event.da taTransfer.getD ata('Text').rep lace(/\<form/gi,"<xform");
oDiv.innerHTML =
window.event.da taTransfer.getD ata('Text').rep lace(/\<\/form/gi,"</xform");
}
document.getEle mentById('xRich TextBox1_oTexta rea').value =
oDiv.innerHTML;
//window.event.da taTransfer.getD ata('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="Up dRichText();"
onbeforepaste=" UpdRichText();" ></DIV>
<asp:TextBox ID="oTextarea" Runat="server" Wrap="False"
TextMode="Multi Line" style="WIDTH: 300; HEIGHT: 300;OVERFLOW: auto;
DISPLAY: none;"></asp:TextBox>

Dec 7 '05 #1
3 3239
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.javas cript 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
5814
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. However, if the user edits the <div> by typing: "john@doe.com is listed on the www.yahoo.com webpage" IE 5.5+ automatically detects the email address and the URL and creates those 2 hyperlinks automatically.
2
1563
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 to use the CallContext.GetData() method to retrieved information from within a method in the Server part, all if fine. If I try to do it from within the Constructor (which is called each time prior a method is executed on the Server ), the...
6
7123
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) { Object item = (object)e.Data.GetData(typeof(AbstractNode)); // Other code }
2
4084
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 save to file. However unlike Word, OneNote does not paste a bitmap compatible image to the clipboard. It does sat is supports EnhancedMetaFile, DeviceIndependentBitmap, OneNote internal or HTML. The first 2 return when used with getdata return...
1
2360
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 don't seem to be similar beasts. Eventually I want to add stylesheets to the contentEditable DIV as well as event handling. I'm porting an IFrame editor to a contentEditable DIV based editor. Thanks, Cliff.
4
7748
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 the setData and getData methods. In IE6/7 the following code is draggable: <img src="Images/TreeIcons/file.gif" border="0" onDragStart="event.dataTransfer.setData('text', '2|16|190');" />
5
3438
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(); IDataObject prevClipboard = new DataObject(); string formats; formats = oldClipboard.GetFormats(); //gets all the possible formats
0
2782
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 microsoft.public.dotnet.framework.windowsforms trying to find a way to access the lindex member of the FORMATETC structure for a CFSTR_FILECONTENTS callback request under C#. After some experimenting I was able to come up with the following code snippet that receives the callback...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.