gpt4 book ai didi

javascript - onDrop 事件转发到 url 但仅在 FireFox 中

转载 作者:行者123 更新时间:2023-11-30 05:43:49 29 4
gpt4 key购买 nike

            <script type="text/javascript" src="jquery-2.0.3.min.js"></script>
<style>
.canvas {
position:relative;
height:550px;
width:400px;
background:Yellow url("http://www.mapstop.co.uk/images/uploaded/lrg_wg2668.6a40d0d.jpg") no-repeat;
}
.canvas img {
position:absolute;
}
</style>
<div class="toolbar">
<span>Drag...</span>
<img src="/image/hoEOi.png" alt="" title="" />
<img src="http://cdn4.iconfinder.com/data/icons/iconsland-weather/PNG/48x48/Thermometer_Snowflake.png" alt="" title="" />
<img src="http://cdn4.iconfinder.com/data/icons/iconsland-weather/PNG/48x48/Overcast.png" alt="" title="" />
<img src="http://cdn4.iconfinder.com/data/icons/iconsland-weather/PNG/48x48/Night_Rain.png" alt="" title="" />
</div>
<div class="canvas"></div>
<script type="text/javascript">
$(document).ready(function () {
var $toolbar = $(".toolbar");
var $tools = $toolbar.find("img");

//define drag and drop handlers
$toolbar.on("dragstart", "img", onDrag);

$(".canvas").on({
dragenter: false,
dragover: false,
drop: onDrop
});

//handle commencement of drag
function onDrag(e) {

console.log("onDrag");
}

//handle drop
function onDrop(e) {

//console.log("OnDrop");
//console.log(e.clientX);
//console.log(e.clientY);
//console.log(e.originalEvent);
}
});
</script>

当我放下图片时,由于某种原因我被转发到 http://cdn4.iconfinder.com/data/icons/iconsland-weather/PNG/48x48/Sunny.png但仅限于 FireFox。 Chrome 和 IE 似乎都采取了预期的行为,即现在什么都不做。也许有人知道为什么会这样?

最佳答案

尝试为拖动输入和拖动指定处理程序并将 e.preventDefault();e.stopPropagation(); 添加到您的处理程序。

关于javascript - onDrop 事件转发到 url 但仅在 FireFox 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19204124/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com