



#
“dropzone”属性について
“dropzone”属性はドラッグして要素にドロップしたアイテムを受け入れるかどうかと、その受け入れ方法を指定する属性です。
ドロップされた後の動作はスクリプトで設定します。
この属性はHTML5.2で廃止されているため使用するべきではありません。
#
#
サンプルコード
<p><img src="sample.png" alt="サンプルの画像" draggable="true"></p>
<div dropzone="copy file:image/png" ondrop="receive(event, this)" style=" height:100px; background-color: rgb(215,206,202);">
ここにドロップされた画像が表示されます。
</div>
<script>
function receive(event, element) {
var data = event.dataTransfer.items;
for (var i = 0; i < data.length; i += 1) {
if ((data[i].kind == 'file') && (data[i].type.match('^image/'))) {
var img = new Image();
img.src = window.createObjectURL(data[i].getAsFile());
element.appendChild(img);
}
}
}
</script>