Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 draggable='false' not working in Firefox browser

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

like image 464
Sandeep Avatar asked Oct 14 '14 09:10

Sandeep


People also ask

How do I make elements draggable in HTML?

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.

Which HTML attribute is used to determine if an element is draggable?

HTML draggable Attribute The draggable attribute specifies whether an element is draggable or not. Tip: Links and images are draggable by default.

What values can you use for the draggable attribute?

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.

Why can’t i drag an element in Firefox?

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:

What does draggable mean in HTML?

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.

What's new in HTML5 and Firefox?

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.

What is the default image type for drag by default in Firefox?

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.


1 Answers

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>
like image 96
isambitd Avatar answered Sep 17 '22 13:09

isambitd