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


            <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="https://i.stack.imgur.com/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();

最新更新