[Pas2js] dataTransfer has a rare performance!??

Michael Van Canneyt michael at freepascal.org
Thu Aug 22 08:48:04 CEST 2019



On Wed, 21 Aug 2019, Pedro Pablo Oviedo Vera wrote:

> Hello people,...yes, me again....look:
>
> ..if in a function like :
> function Arrastrar(aEvent:TJSDragEvent): Boolean;
> begin
>  aEvent.dataTransfer.setData('Text','<img src="'+
> FOrg1.getAttribute('src')+'" >');
> end;
>
>
> with FOrg1.getAttribute('src') >> '/synapse/synapse_logo.gif'
>
> ...and later:
>
> function Soltar(aEvent:TJSDragEvent):Boolean;
> begin
>   FDest.innerHTML:= aEvent.dataTransfer.getData('Text');
>   aEvent.preventDefault;
> end;
> ...
> why FDest.InnerHTML just shows '/synapse/synapse_logo.gif' instead of  <img
> src="/synapse/synapse_logo.gif" > ??
>
> any idea?

Try logging aEvent.dataTransfer.getData('Text') in your Soltar event. I
suspect that because you use Text, it transforms whatever is inside the data
to plain text. If so, try using 'text/html' instead of Text.

Michael.


More information about the Pas2js mailing list