0

I've read Is html5 drag and drop broken on safari browser for windows? several times, looked at countless other resources, but can't solve my problem with the top answer.

This is the code, if someone could modify it so that it works on Safari that would be much appreciated. The dragged html snippet is logged in the console on chrome, but not in safari. I'm quite new to js so need something verbose! thank you

$(window).load(function(){
   var dropbox = document.getElementById('image-drop-block');
   dropbox.addEventListener('dragenter', noopHandler, false);
   dropbox.addEventListener('dragexit', noopHandler, false);
   dropbox.addEventListener('dragover', noopHandler, false);
   dropbox.addEventListener('drop', drop, false);
   dropbox.addEventListener('dragend',noopHandler, false);

   function noopHandler(evt) {
   evt.stopPropagation();
   evt.preventDefault();
   }                

   function drop(evt) {
   evt.preventDefault();
   var droppedHTML = evt.dataTransfer.getData("text/html");
   console.log(droppedHTML);
   }
});
Community
  • 1
  • 1

1 Answers1

0

I see that the load function is not properly closed " ); ", this might be a typo? Do you have a working solution?

Erick Boshoff
  • 1,443
  • 2
  • 18
  • 30
  • I updated the question - thanks. Yes - solution works in chrome and firefox, but not safari – Steven Shinn Apr 28 '16 at 14:02
  • I know this might not be the right answer but I had the same problem in safari. This post gave me some more insight to safari's drag and drop graphics. Here is the link: [link](http://www.useragentman.com/blog/2010/01/10/cross-browser-html5-drag-and-drop/) – Erick Boshoff Apr 28 '16 at 14:08
  • Hi Eric - I found that, but I couldn't solve my problem. Thanks for trying. – Steven Shinn Apr 28 '16 at 14:11