Disable the drag-and-drop for textDetect file type on dragenter cross browser solutionGetting the filename during the dragenter eventjQuery get specific option tag textDisable Drag and Drop on HTML elements?Disable/enable an input with jQuery?Get selected text from a drop-down list (select box) using jQueryDisable same origin policy in ChromeHow do I prevent drag on a child, but allow drag on the parent?How does Facebook disable the browser's integrated Developer Tools?HTML5 drag and drop element over div with Hammer.js drag eventsjQuery Drag & Drop - only allow drags from outside the browserdrag to browser and detect mime of file being dropped
What's the idiomatic (or best) way to trim surrounding whitespace from a string?
Disk usage confusion: 10G missing on Linux home partition on SSD
How soon after takeoff can you recline your airplane seat?
How to remove system locales
A quine of sorts
How useful would a hydroelectric power plant be in the post-apocalypse world?
How much of a mortgage should I take on to maximize my 5 year financial plan?
Rear derailleur got caught in the spokes, what could be a root cause
Why did the Apple IIe make a hideous noise if you inserted the disk upside down?
Any Tips On Writing Extended Recollection In A Novel
Solve limit without using L'Hopital (first year problem for first year solution, not graduate level)
A* pathfinding algorithm too slow
How does the 'five minute adventuring day' affect class balance?
Is it OK to say "The situation is pregnant with a crisis"?
Why is my 401k manager recommending me to save more?
Did NASA distinguish between the space shuttle cockpit and flight deck?
Chandra exiles a card, I play it, it gets exiled again
Basis and cardinality
How to track mail undetectably?
What was the point of separating stdout and stderr?
Why do movie directors use brown tint on Mexico cities?
Can I deep fry food in butter instead of vegetable oil?
Why didn't Avengers simply jump 5 years back?
Advantages of using bra-ket notation
Disable the drag-and-drop for text
Detect file type on dragenter cross browser solutionGetting the filename during the dragenter eventjQuery get specific option tag textDisable Drag and Drop on HTML elements?Disable/enable an input with jQuery?Get selected text from a drop-down list (select box) using jQueryDisable same origin policy in ChromeHow do I prevent drag on a child, but allow drag on the parent?How does Facebook disable the browser's integrated Developer Tools?HTML5 drag and drop element over div with Hammer.js drag eventsjQuery Drag & Drop - only allow drags from outside the browserdrag to browser and detect mime of file being dropped
I am developing a drag-and-drop system for image files and I have noticed that the dragenter
event is also executed on the selected text drag.
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
// Check if we are dragging text
if(is_text) // <- HERE
console.log("dragging text!");
else
console.log("dragging file!");
);
I want to detect that the dragged object is not text, so the previous console.log
would not run if it were.
UPDATE AND SOLUTION:
var dragging_text = false;
$(window).on("dragstart", function(event)
dragging_text = true;
console.log("dragstart");
);
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
if(dragging_text)
console.log("NO, dragging text!");
else
console.log("OK, dragging file!");
);
javascript jquery drag-and-drop
add a comment |
I am developing a drag-and-drop system for image files and I have noticed that the dragenter
event is also executed on the selected text drag.
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
// Check if we are dragging text
if(is_text) // <- HERE
console.log("dragging text!");
else
console.log("dragging file!");
);
I want to detect that the dragged object is not text, so the previous console.log
would not run if it were.
UPDATE AND SOLUTION:
var dragging_text = false;
$(window).on("dragstart", function(event)
dragging_text = true;
console.log("dragstart");
);
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
if(dragging_text)
console.log("NO, dragging text!");
else
console.log("OK, dragging file!");
);
javascript jquery drag-and-drop
just not understand what you mean by text, you can not drag and drop text !
– mooga
Mar 25 at 16:39
@mooga Thedragenter
event fires when you select and drag text. I want to avoid it.
– Smark
Mar 25 at 16:41
add a comment |
I am developing a drag-and-drop system for image files and I have noticed that the dragenter
event is also executed on the selected text drag.
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
// Check if we are dragging text
if(is_text) // <- HERE
console.log("dragging text!");
else
console.log("dragging file!");
);
I want to detect that the dragged object is not text, so the previous console.log
would not run if it were.
UPDATE AND SOLUTION:
var dragging_text = false;
$(window).on("dragstart", function(event)
dragging_text = true;
console.log("dragstart");
);
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
if(dragging_text)
console.log("NO, dragging text!");
else
console.log("OK, dragging file!");
);
javascript jquery drag-and-drop
I am developing a drag-and-drop system for image files and I have noticed that the dragenter
event is also executed on the selected text drag.
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
// Check if we are dragging text
if(is_text) // <- HERE
console.log("dragging text!");
else
console.log("dragging file!");
);
I want to detect that the dragged object is not text, so the previous console.log
would not run if it were.
UPDATE AND SOLUTION:
var dragging_text = false;
$(window).on("dragstart", function(event)
dragging_text = true;
console.log("dragstart");
);
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
if(dragging_text)
console.log("NO, dragging text!");
else
console.log("OK, dragging file!");
);
javascript jquery drag-and-drop
javascript jquery drag-and-drop
edited Mar 26 at 10:17
Smark
asked Mar 25 at 16:34
SmarkSmark
598 bronze badges
598 bronze badges
just not understand what you mean by text, you can not drag and drop text !
– mooga
Mar 25 at 16:39
@mooga Thedragenter
event fires when you select and drag text. I want to avoid it.
– Smark
Mar 25 at 16:41
add a comment |
just not understand what you mean by text, you can not drag and drop text !
– mooga
Mar 25 at 16:39
@mooga Thedragenter
event fires when you select and drag text. I want to avoid it.
– Smark
Mar 25 at 16:41
just not understand what you mean by text, you can not drag and drop text !
– mooga
Mar 25 at 16:39
just not understand what you mean by text, you can not drag and drop text !
– mooga
Mar 25 at 16:39
@mooga The
dragenter
event fires when you select and drag text. I want to avoid it.– Smark
Mar 25 at 16:41
@mooga The
dragenter
event fires when you select and drag text. I want to avoid it.– Smark
Mar 25 at 16:41
add a comment |
2 Answers
2
active
oldest
votes
This will help you know:
var dragging_text = false;
$(window).on("dragstart", function(event)
dragging_text = true;
console.log("dragstart");
);
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
if(dragging_text)
console.log("NO, dragging text!");
else
console.log("OK, dragging file!");
dragging_text = false;
);
I've researched aboutdragstart
and it seems to work fine. I update the post with my solution.
– Smark
Mar 26 at 10:18
Don't forget to add 'dragging_text = false;' in the dragenter() event, tell me if it works.
– Richard Socker
Mar 26 at 10:33
Thanks, I forgot to includedragging_text = false;
indragenter
event. I've done tests and it seems to work fine.
– Smark
Mar 26 at 10:44
add a comment |
You need to check DataTransfer
$(document).on("dragenter", "#element", function(event)
if(event.dataTransfer.files.length > 0) // <- HERE
console.log("dragenter");
else
event.preventDefault();
);
I have updated the question to see if it is better understood now.
– Smark
Mar 25 at 16:48
have usedif(event.dataTransfer.files.length > 0){
?
– mooga
Mar 25 at 16:52
Yes, but with that line it does not let me drag files.
– Smark
Mar 25 at 16:56
because you block it anyway, i have changed the code , try it
– mooga
Mar 25 at 17:00
dataTransfer
works in thedragenter
event? I have documented and I have seen that it does not work.
– Smark
Mar 25 at 17:05
|
show 7 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55342477%2fdisable-the-drag-and-drop-for-text%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This will help you know:
var dragging_text = false;
$(window).on("dragstart", function(event)
dragging_text = true;
console.log("dragstart");
);
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
if(dragging_text)
console.log("NO, dragging text!");
else
console.log("OK, dragging file!");
dragging_text = false;
);
I've researched aboutdragstart
and it seems to work fine. I update the post with my solution.
– Smark
Mar 26 at 10:18
Don't forget to add 'dragging_text = false;' in the dragenter() event, tell me if it works.
– Richard Socker
Mar 26 at 10:33
Thanks, I forgot to includedragging_text = false;
indragenter
event. I've done tests and it seems to work fine.
– Smark
Mar 26 at 10:44
add a comment |
This will help you know:
var dragging_text = false;
$(window).on("dragstart", function(event)
dragging_text = true;
console.log("dragstart");
);
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
if(dragging_text)
console.log("NO, dragging text!");
else
console.log("OK, dragging file!");
dragging_text = false;
);
I've researched aboutdragstart
and it seems to work fine. I update the post with my solution.
– Smark
Mar 26 at 10:18
Don't forget to add 'dragging_text = false;' in the dragenter() event, tell me if it works.
– Richard Socker
Mar 26 at 10:33
Thanks, I forgot to includedragging_text = false;
indragenter
event. I've done tests and it seems to work fine.
– Smark
Mar 26 at 10:44
add a comment |
This will help you know:
var dragging_text = false;
$(window).on("dragstart", function(event)
dragging_text = true;
console.log("dragstart");
);
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
if(dragging_text)
console.log("NO, dragging text!");
else
console.log("OK, dragging file!");
dragging_text = false;
);
This will help you know:
var dragging_text = false;
$(window).on("dragstart", function(event)
dragging_text = true;
console.log("dragstart");
);
$(document).on("dragenter", "#element", function(event)
event.preventDefault();
if(dragging_text)
console.log("NO, dragging text!");
else
console.log("OK, dragging file!");
dragging_text = false;
);
edited Mar 26 at 10:32
answered Mar 26 at 9:43
Richard SockerRichard Socker
24110 bronze badges
24110 bronze badges
I've researched aboutdragstart
and it seems to work fine. I update the post with my solution.
– Smark
Mar 26 at 10:18
Don't forget to add 'dragging_text = false;' in the dragenter() event, tell me if it works.
– Richard Socker
Mar 26 at 10:33
Thanks, I forgot to includedragging_text = false;
indragenter
event. I've done tests and it seems to work fine.
– Smark
Mar 26 at 10:44
add a comment |
I've researched aboutdragstart
and it seems to work fine. I update the post with my solution.
– Smark
Mar 26 at 10:18
Don't forget to add 'dragging_text = false;' in the dragenter() event, tell me if it works.
– Richard Socker
Mar 26 at 10:33
Thanks, I forgot to includedragging_text = false;
indragenter
event. I've done tests and it seems to work fine.
– Smark
Mar 26 at 10:44
I've researched about
dragstart
and it seems to work fine. I update the post with my solution.– Smark
Mar 26 at 10:18
I've researched about
dragstart
and it seems to work fine. I update the post with my solution.– Smark
Mar 26 at 10:18
Don't forget to add 'dragging_text = false;' in the dragenter() event, tell me if it works.
– Richard Socker
Mar 26 at 10:33
Don't forget to add 'dragging_text = false;' in the dragenter() event, tell me if it works.
– Richard Socker
Mar 26 at 10:33
Thanks, I forgot to include
dragging_text = false;
in dragenter
event. I've done tests and it seems to work fine.– Smark
Mar 26 at 10:44
Thanks, I forgot to include
dragging_text = false;
in dragenter
event. I've done tests and it seems to work fine.– Smark
Mar 26 at 10:44
add a comment |
You need to check DataTransfer
$(document).on("dragenter", "#element", function(event)
if(event.dataTransfer.files.length > 0) // <- HERE
console.log("dragenter");
else
event.preventDefault();
);
I have updated the question to see if it is better understood now.
– Smark
Mar 25 at 16:48
have usedif(event.dataTransfer.files.length > 0){
?
– mooga
Mar 25 at 16:52
Yes, but with that line it does not let me drag files.
– Smark
Mar 25 at 16:56
because you block it anyway, i have changed the code , try it
– mooga
Mar 25 at 17:00
dataTransfer
works in thedragenter
event? I have documented and I have seen that it does not work.
– Smark
Mar 25 at 17:05
|
show 7 more comments
You need to check DataTransfer
$(document).on("dragenter", "#element", function(event)
if(event.dataTransfer.files.length > 0) // <- HERE
console.log("dragenter");
else
event.preventDefault();
);
I have updated the question to see if it is better understood now.
– Smark
Mar 25 at 16:48
have usedif(event.dataTransfer.files.length > 0){
?
– mooga
Mar 25 at 16:52
Yes, but with that line it does not let me drag files.
– Smark
Mar 25 at 16:56
because you block it anyway, i have changed the code , try it
– mooga
Mar 25 at 17:00
dataTransfer
works in thedragenter
event? I have documented and I have seen that it does not work.
– Smark
Mar 25 at 17:05
|
show 7 more comments
You need to check DataTransfer
$(document).on("dragenter", "#element", function(event)
if(event.dataTransfer.files.length > 0) // <- HERE
console.log("dragenter");
else
event.preventDefault();
);
You need to check DataTransfer
$(document).on("dragenter", "#element", function(event)
if(event.dataTransfer.files.length > 0) // <- HERE
console.log("dragenter");
else
event.preventDefault();
);
edited Mar 25 at 16:59
answered Mar 25 at 16:41
moogamooga
1,5604 gold badges12 silver badges25 bronze badges
1,5604 gold badges12 silver badges25 bronze badges
I have updated the question to see if it is better understood now.
– Smark
Mar 25 at 16:48
have usedif(event.dataTransfer.files.length > 0){
?
– mooga
Mar 25 at 16:52
Yes, but with that line it does not let me drag files.
– Smark
Mar 25 at 16:56
because you block it anyway, i have changed the code , try it
– mooga
Mar 25 at 17:00
dataTransfer
works in thedragenter
event? I have documented and I have seen that it does not work.
– Smark
Mar 25 at 17:05
|
show 7 more comments
I have updated the question to see if it is better understood now.
– Smark
Mar 25 at 16:48
have usedif(event.dataTransfer.files.length > 0){
?
– mooga
Mar 25 at 16:52
Yes, but with that line it does not let me drag files.
– Smark
Mar 25 at 16:56
because you block it anyway, i have changed the code , try it
– mooga
Mar 25 at 17:00
dataTransfer
works in thedragenter
event? I have documented and I have seen that it does not work.
– Smark
Mar 25 at 17:05
I have updated the question to see if it is better understood now.
– Smark
Mar 25 at 16:48
I have updated the question to see if it is better understood now.
– Smark
Mar 25 at 16:48
have used
if(event.dataTransfer.files.length > 0){
?– mooga
Mar 25 at 16:52
have used
if(event.dataTransfer.files.length > 0){
?– mooga
Mar 25 at 16:52
Yes, but with that line it does not let me drag files.
– Smark
Mar 25 at 16:56
Yes, but with that line it does not let me drag files.
– Smark
Mar 25 at 16:56
because you block it anyway, i have changed the code , try it
– mooga
Mar 25 at 17:00
because you block it anyway, i have changed the code , try it
– mooga
Mar 25 at 17:00
dataTransfer
works in the dragenter
event? I have documented and I have seen that it does not work.– Smark
Mar 25 at 17:05
dataTransfer
works in the dragenter
event? I have documented and I have seen that it does not work.– Smark
Mar 25 at 17:05
|
show 7 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55342477%2fdisable-the-drag-and-drop-for-text%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
just not understand what you mean by text, you can not drag and drop text !
– mooga
Mar 25 at 16:39
@mooga The
dragenter
event fires when you select and drag text. I want to avoid it.– Smark
Mar 25 at 16:41