Results 1 to 5 of 5

Thread: how do you find the file type of what the mouse is dragging?

  1. #1
    Join Date
    Aug 2011

    how do you find the file type of what the mouse is dragging?

    just as the title says. i have been looking for days about how to find what the mouse is dragging to switch the ondragover event between true and preventDefault. i am on 5 forums and searching every second under different terms, does this mean i'm not socializing properly or does this answer just not exist! does anyone actually read these threads?

  2. #2
    Join Date
    Apr 2006
    Your question is something I have never had to answer myself. The logistics of
    recreating what you have is beyond my care, bother and energy. You've expressed
    yourself clearly enough but never supplied enough source for me to bother examining.

    An online attempt would be helpful. If it is a complicated setup comprising more than 2
    or 3 files, then I'd want to download the entire project as one ZIP file.

    If you can supply a concise example featuring only an in-page object or two to drag and
    a place to drag them, with a specifically acceptable external file to test, then I'd be
    willing to investigate further.

    Show me some effort and I'll return the favour.
    Colin Fiat Simple Solutions To Complex Problems

  3. #3
    Join Date
    Apr 2006
    Ok, I did a big of digging into the contents of an onDragOver event using IE7 by
    attempting to alert(event); which caused an instant hang. Debugging IE7 and
    navigating my way up the return stack, I managed to locate a chained list of nodes.

    There are a heap of values associated with an event: mouse x and y relative to the
    page and screen, source element object, event type and so on. All the thing you
    already know or don't care about. ALT/SHIFT/CTRL keys, button number and so on.
    Even something caled 'wheelDelta' but I do not know if that has anything to do with
    the mouse wheel.

    Then I found an attribute of the event called dataTransfer:


    Tests show that dropping an image or page text gives a dropEffect of 'copy' and
    dropping editable text gives a value of 'none'. effectAllowed always contains

    I am still not sure how you managed to drag and drop a file object onto the browser
    without having it evaluate the type automatically and either load the object into the
    page or launch an associated application for the data type.

    Here is an example of drag and drop from Microsoft:

    And here are al the attributes of the onDragOver event from MS:
    Colin Fiat Simple Solutions To Complex Problems

  4. #4
    Join Date
    Aug 2011
    ok, i'm sure it's poorly constructed but like i have about one week with javascript but two years with php
    $listen ="\n<script>
    function prDe(){ event.preventDefault(); };
    var holder = document.getElementById('article');
    holder.ondragover = function () { prDe(); };
    holder.ondrop = function (e) {
    var file = e.dataTransfer.files[0],
    reader = new FileReader();
    reader.onload = function (event) {
    var Img_Src =event.target.result;
    document.execCommand('InsertImage',null,Img_Src); };
    return false; };
    //  Backup send for image upload>>>>>>>>>>>>>>>>>>>>>>>>>
    //  var xmlhttp;
    //  xmlhttp=new XMLHttpRequest(); 
    //  xmlhttp.onreadystatechange=function()
    //  {
    //  document.getElementById('condition_return').innerHTML=xmlhttp.responseText;}
    //  xmlhttp.open(\"POST\",\"index_services/upload.php\",true);
    //  xmlhttp.setRequestHeader(\"Content-Type\",\"application/x-www-form-urlencoded\");
    //  xmlhttp.send(\"send=\" + Img_Src + \"&page_pointer=$page_pointer&key=$fetch_user_session_data[0]\"); 
    if(isset($_GET[page])){ $page_pointer =$_GET[page]; }
    else{ $page_pointer ="home"; }
    $cms_html ="
    <div id='cms_tools_upper'>
    <button onclick=\"document.execCommand('justifyleft');\">Justify Left</button>
    <button onclick=\"document.execCommand('justifycenter');\">Justify Center</button>
    <button onclick=\"document.execCommand('justifyright');\">Justify Right</button>
    <button onclick=\"mL();\">Margin Left</button>
    <button onclick=\"mR();\">Margin Right</button>
    <button onclick=\"document.execCommand('outdent');\">Outdent</button>
    <button onclick=\"document.execCommand('indent');\">Indent</button>
    <button onclick=\"document.execCommand('subscript');\"><sub style='color: inherit; font-family: inherit;'>Sub</sub>script</button>
    <button onclick=\"document.execCommand('superscript');\"><sup style='color: inherit; font-family: inherit;'>Super</sup>script</button>
    <button onclick=\"document.execCommand('strikethrough');\"><strike style='color: inherit; font-family: inherit;'>Strike</strike></button>
    <button onclick=\"document.execCommand('underline');\"><u style='color: inherit; font-family: inherit;'>U</u></button>
    <button onclick=\"document.execCommand('italic');\"><i style='color: inherit; font-family: inherit;'>i</i></button>
    <button onclick=\"document.execCommand('bold');\"><b style='color: inherit; font-family: inherit;'>B</b></button>
    <button onclick=\"document.execCommand('fontSize', false, '1');\">X1</button>
    <button onclick=\"document.execCommand('fontSize', false, '2');\">X2</button>
    <button onclick=\"document.execCommand('fontSize', false, '3');\">X3</button>
    <button onclick=\"document.execCommand('fontSize', false, '4');\">X4</button>
    <button onclick=\"document.execCommand('fontSize', false, '5');\">X5</button>
    <div id='cms_tools_lower'>
    <div id='condition_return'></div>
    <button onclick=\"ADDsection();\">Section</button>
    <button onclick=\"document.execCommand('formatblock',false,'p');\">P</button>
    <button onclick=\"document.execCommand('formatblock',false,'H1');\">H1</button>
    <button onclick=\"document.execCommand('formatblock',false,'H2');\">H2</button>
    <button onclick=\"document.execCommand('formatblock',false,'H3');\">H3</button>
    <button onclick=\"document.execCommand('formatblock',false,'H4');\">H4</button>
    <button onclick=\"document.execCommand('formatblock',false,'H5');\">H5</button>
    <button onclick=\"document.execCommand('formatblock',false,'H6');\">H6</button>
    <button onclick=\"document.execCommand('InsertHorizontalRule');\">HR</button>
    <button onclick=\"document.execCommand('InsertUnorderedList');\">UL</button>
    <button onclick=\"document.execCommand('InsertOrderedList');\">OL</button>
    <button onclick=\"document.execCommand('insertHTML', false, prompt('HTML', ''));\">HTML</button>
    <a onclick=\"document.getElementById('slide').setAttribute('class','slide_open'); document.getElementById('ic').setAttribute('class','open');\">Image</a>
    <button onclick=\"document.execCommand('createLink', false, prompt('Enter a URL:', 'http://'));\">Link</button>
    <button onclick=\"document.execCommand('Undo');\">Undo</button>
    <button onclick=\"document.execCommand('redo');\">Redo</button>
    <a href='$site/dashboard'>Dashboard</a>
    <button onclick=\"loadXMLDoc();\">Save</button>
    <div id='ic' class='xclose'>
    <button onclick=\"document.getElementById('slide').setAttribute('class','slide_close'); document.getElementById('ic').setAttribute('class','xclose');\">Close</button>
    <div id='slide' class='slide_close'>
    $cms_css ="\n<link rel=\"stylesheet\" type=\"text/css\" href=\"index_services/cms.css\" />";
    $cms_js ="\n<script type=\"text/javascript\">
    function ADDsection() {
    var genId = \"\";
    var possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";
    for( var i=0; i < 27; i++ )
    genId += possible.charAt(Math.floor(Math.random() * possible.length));
    var pageHolder=document.getElementById('article').innerHTML;
    modPage =pageHolder + \"<section id='\" + genId + \"' class='section' contenteditable='true'>New Section</section>\";
    document.getElementById('article').innerHTML= modPage; }
    function mL() {
    var setMarginLeft=prompt('Left Margin', '') +'px';
    function mR() {
    var setMarginRight=prompt('Right Margin', '') +'px';
    function loadXMLDoc()
    var tmpDOC = document.getElementById('article');
    document.execCommand('SelectAll', true);
    var senDOC =encodeURIComponent(tmpDOC.innerHTML);
    var xmlhttp;
    if (window.XMLHttpRequest)
    { xmlhttp=new XMLHttpRequest(); }
    { xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\"); }
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    document.execCommand('Unselect', true);
    document.getElementById('condition_return').innerHTML=xmlhttp.responseText; }}
    xmlhttp.send(\"send=\" + senDOC + \"&page_pointer=$page_pointer&key=$fetch_user_session_data[0]\");} 
    the variables are included as follows

    <article contenteditable='true'>


  5. #5
    Join Date
    Apr 2006
    Sorry Dorky, I have zero knowledge of PHP - none nada zip! I know JavaScript.

    Have you seen this page: https://www.ibm.com/developerworks/m...page28?lang=en

    AJAX example that does not work for me: http://blog.justswell.org/drag-and-d...ng-javascript/

    Read up on The File API

    This seems to work for images: http://www.thecssninja.com/javascript/fileapi

    Here is one which is more descriptive: http://www.ajaxline.com/drag-and-drop-files-in-browsers
    Colin Fiat Simple Solutions To Complex Problems

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11137 seconds
  • Memory Usage 2,906KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (5)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates