简体   繁体   English

我的拖放功能解决方案在Firefox中不起作用

[英]my solution for drag drop functionality is not working in firefox

I'm implementing simple drag and drop functionality into my website. 我正在将简单的拖放功能实现到我的网站中。 It works fine as per drag and drop of image concerns. 根据图像的拖放效果,它可以正常工作。 However, now I want to save dropped image into the server. 但是,现在我想将删除的图像保存到服务器中。 For that I have included data regarding image in view as hidden elements, to access this data in jQuery I need dropped image id. 为此,我已经将视图中的图像数据作为隐藏元素包括在内,要在jQuery中访问此数据,我需要删除图像ID。 I have tried getting this from following code it work's great in chrome but doesn't in firefox please help : 我尝试从以下代码中获取此代码,它在chrome中效果很好,但在Firefox中效果不佳,请帮助:

code: 码:

 view <!-- dragable image -->
        <a href="#?w=976" rel="popup1" id="<?=$album['album_id'].'-'.$data->content_id?>" class="poplight album_photos"><img  id="<?=$album['album_id'].'-'.$data->content_id?>" draggable="true" ondragstart="drag(event)" ondragover="allowDrop(event)" alt="" src="<?=$imagePath?>"></a>
                                <input type="hidden" id="<?='wall'.$data->content_id?>" value="<?=$data->wall_id?>"/>
                                <input type="hidden" id="<?='type'.$data->content_id?>" value="<?=$data->content_type?>"/>
                                <input type="hidden" id="<?='user'.$data->content_id?>" value="<?=$_SESSION['user_type']?>"/> 

     <!-- dropable area --> 

<div class="" style="z-index: 1; position:fixed; right:124px; top:60px" id="div1" ondrop="drop(event);;" ondragover="allowDrop(event);"> <a href="#"><img id="dropzon_image"src="<?php echo IMAGE_PATH_HTTP?>babbler_btn.jpg" alt="" border="0" style="cursor: pointer; cursor: hand; "/></a><div id="overlay" style="display:none;z-index: 2;  position:fixed; right:0px; top:32px; cursor: pointer;border-color: blueviolet;"><img id="drop_image"src="<?php echo IMAGE_PATH_HTTP?>drop_image.jpg" alt="" border="1" style="cursor: pointer; cursor: hand; "/> </div></div>

/*js */
function allowDrop(ev)
    {    
            ev.preventDefault();

    }

function drag(ev)
    {      
            ev.dataTransfer.setData("Text",ev.target.id);
               $("#div1").find("#overlay").slideDown();
               setTimeout( function(){$("#overlay").hide();} , 4000);

    }

function drop(ev)
    {     

         var id = ev.dataTransfer.getData("Text");/*implimented solution*/ 

         alert(id);


              ev.preventDefault();
             var action='download';
             var wall_id='62';
             var stat = 'Album';
             var cnt ='0';
             var user_type='R';
             var status = do_download(action,wall_id,stat,cnt,user_type);

         $("#overlay").hide();

           // ev.target.appendChild(document.getElementById(data));
    }

http://jsfiddle.net/TFv3a/ http://jsfiddle.net/TFv3a/

<a id="dragable" style="display:block;width:100px;height:100px;border:1px solid red;">Drag here</a>

document.getElementById('dragable').ondragover = function(e){e.preventDefault();  }
document.getElementById('dragable').ondrop = function(e){ upload_drop(e); }


function upload_drop(e){
e.preventDefault();
alert('drag and drop works.');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM