过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

Removed in Firefox 50, and never implemented in any other browser. Use the modern standard HTML5 drag and drop feature instead.

摘要

An event handler for drag and drop events sent to the window.

句法

window.ondragdrop = funcRef;
window.addEventListener("dragdrop", funcRef, useCapturing);
					
funcRef

The event handler function to be registered.

window.ondragdrop 特性和 ondragdrop attribute are not implemented in Gecko ( bug 112288 ), you have to use addEventListener 。见 addEventListener 了解细节。

范例

Fire an alert on dragdrop

In this example, an event listener is added to the window (the event target). If, from an external source, a tab, a link, marked text or a file is dragged and dropped onto this window, the alert is fired. Note how event.stopPropagation(); prevents the browser from loading the dropped tab, link or file.

<html>
<head><title>dragdroptest</title>
<script type="text/javascript">
window.addEventListener("dragdrop", testfunc, false);
function testfunc(event) {
    alert("dragdrop!");
    event.stopPropagation();
}
</script>
</head>
<body>
I am bodytext
</body>
</html>
					

规范

Not part of specification.

元数据

  • 最后修改:
  1. Window
  2. 特性
    1. applicationCache
    2. caches
    3. closed
    4. console
    5. controllers
    6. crypto
    7. customElements
    8. defaultStatus
    9. devicePixelRatio
    10. dialogArguments
    11. 目录
    12. document
    13. frameElement
    14. frames
    15. fullScreen
    16. history
    17. indexedDB
    18. innerHeight
    19. innerWidth
    20. isSecureContext
    21. isSecureContext
    22. length
    23. localStorage
    24. location
    25. locationbar
    26. menubar
    27. mozAnimationStartTime
    28. mozInnerScreenX
    29. mozInnerScreenY
    30. mozPaintCount
    31. 名称
    32. navigator
    33. onabort
    34. onafterprint
    35. onanimationcancel
    36. onanimationend
    37. onanimationiteration
    38. onappinstalled
    39. onauxclick
    40. onbeforeinstallprompt
    41. onbeforeprint
    42. onbeforeunload
    43. onblur
    44. oncancel
    45. oncanplay
    46. oncanplaythrough
    47. onchange
    48. onclick
    49. onclose
    50. oncontextmenu
    51. oncuechange
    52. ondblclick
    53. ondevicelight
    54. ondevicemotion
    55. ondeviceorientation
    56. ondeviceorientationabsolute
    57. ondeviceproximity
    58. ondragdrop
    59. ondurationchange
    60. onended
    61. onerror
    62. onfocus
    63. ongamepadconnected
    64. ongamepaddisconnected
    65. ongotpointercapture
    66. onhashchange
    67. oninput
    68. oninvalid
    69. onkeydown
    70. onkeypress
    71. onkeyup
    72. onlanguagechange
    73. onload
    74. onloadeddata
    75. onloadedmetadata
    76. onloadend
    77. onloadstart
    78. onlostpointercapture
    79. onmessage
    80. onmessageerror
    81. onmousedown
    82. onmouseenter
    83. onmouseleave
    84. onmousemove
    85. onmouseout
    86. onmouseover
    87. onmouseup
    88. onmozbeforepaint
    89. onpaint
    90. onpause
    91. onplay
    92. onpointercancel
    93. onpointerdown
    94. onpointerenter
    95. onpointerleave
    96. onpointermove
    97. onpointerout
    98. onpointerover
    99. onpointerup
    100. onpopstate
    101. onrejectionhandled
    102. onreset
    103. onresize
    104. onscroll
    105. onselect
    106. onselectionchange
    107. onselectstart
    108. onstorage
    109. onsubmit
    110. ontouchcancel
    111. ontouchstart
    112. ontransitioncancel
    113. ontransitionend
    114. onunhandledrejection
    115. onunload
    116. onuserproximity
    117. onvrdisplayactivate
    118. onvrdisplayblur
    119. onvrdisplayconnect
    120. onvrdisplaydeactivate
    121. onvrdisplaydisconnect
    122. onvrdisplayfocus
    123. onvrdisplaypresentchange
    124. onwheel
    125. opener
    126. origin
    127. outerHeight
    128. outerWidth
    129. pageYOffset
    130. parent
    131. 性能
    132. personalbar
    133. pkcs11
    134. screen
    135. screenLeft
    136. screenTop
    137. screenX
    138. screenY
    139. scrollbars
    140. scrollMaxX
    141. scrollMaxY
    142. scrollX
    143. scrollY
    144. self
    145. sessionStorage
    146. sidebar
    147. speechSynthesis
    148. status
    149. statusbar
    150. toolbar
    151. top
    152. visualViewport
    153. window
    154. windowState
  3. 方法
    1. alert()
    2. atob()
    3. back()
    4. blur()
    5. btoa()
    6. cancelAnimationFrame()
    7. cancelIdleCallback()
    8. captureEvents()
    9. clearImmediate()
    10. clearInterval()
    11. clearTimeout()
    12. close()
    13. confirm()
    14. convertPointFromNodeToPage()
    15. convertPointFromPageToNode
    16. createImageBitmap()
    17. dump()
    18. event
    19. fetch()
    20. find()
    21. focus()
    22. forward()
    23. getAttention()
    24. getComputedStyle()
    25. getDefaultComputedStyle()
    26. getSelection()
    27. home()
    28. matchMedia()
    29. minimize()
    30. moveBy()
    31. moveTo()
    32. open()
    33. openDialog()
    34. postMessage()
    35. print()
    36. prompt()
    37. releaseEvents()
    38. requestAnimationFrame()
    39. requestFileSystem()
    40. requestIdleCallback()
    41. resizeBy()
    42. resizeTo()
    43. restore()
    44. routeEvent()
    45. scroll()
    46. scrollBy()
    47. scrollByLines()
    48. scrollByPages()
    49. scrollTo()
    50. setCursor()
    51. setImmediate()
    52. setInterval()
    53. setTimeout()
    54. showModalDialog()
    55. sizeToContent()
    56. stop()
    57. updateCommands()