I'm simply trying to apply HTML5 draggable='false' attribute to some images but it's not working in Firefox browser. In Chrome working fine but on Firefox, after selecting that image able to drag and drop. Sample code can be seen here:
<div id="dnd">
<textarea placeholder="drop here"></textarea>
<img src="http://johnlewis.scene7.com/is/image/JohnLewis/231108668?$prod_main$" draggable='false'/>
</div>
Jsfiddle
I'm having Firefox latest version: 32.0.3
Google a lot but didn't find any better solution. Is there any solution for this without using JavaScript? Any help would be appreciated.
Thanks
To make an object draggable set draggable=true on that element. Just about anything can be drag-enabled: images, files, links, files, or any markup on your page.
HTML draggable Attribute The draggable attribute specifies whether an element is draggable or not. Tip: Links and images are draggable by default.
The draggable attribute can have the following values: true: the element can be draggable. false: the element cannot be draggable. auto: drag is the default browser behavior.
However, Firefox won’t allow you to drag the element unless you manually set some data to go with it. To solve this, we need a dragstart event handler, and we’ll give it some data to be dragged around with:
draggable The draggable global attribute is an enumerated attribute that indicates whether the element can be dragged, either with native browser behavior or the HTML Drag and Drop API. draggable can have the following values: true: the element can be dragged.
The new first-class drag and drop events in HTML5 and Firefox make supporting this form of UI interaction simple, concise, and powerful in the browser.
By default in Firefox, this is a “ghost” image of the dragged element itself. But, the dataTransfer property of the original Event object exposes the method setDragImage () for use in customizing this representation.
just try this
add ondragstart="return false;" to your html element
<div id="dnd">
<textarea placeholder="drop here"></textarea>
<img src="http://johnlewis.scene7.com/is/image/JohnLewis/231108668?$prod_main$" draggable='false' ondragstart="return false;"/>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With