jquery dialog: dragging dialog with iframe inside

2019-03-30 08:54发布

问题:

When dragging a jquery dialog with an iframe inside , the drag stops if the mouse goes over the frame contents while dragging. It seems that the iframe takes automatically the focus. is there any way to prevent this and make drag normal?

var iframe=document.createElement('IFRAME');    
$(div).append(iframe)
       .dialog();

回答1:

It's just my guess, but I'd try covering everything with a transparent div 100% width&height while dragging and assuring it's above iframes and under the dragged thingie :)



回答2:

from naugtur suggestion i found this good working solution:

dragStart:function(){
    var divt=document.createElement('div');
    $(divt).attr('id','tempdragdiv');
     divt.style.height='93%';
    divt.style.width='100%';
    $(divt).css('position','absolute').css('left','0')  .css('top','0');                    
    $(div).append(divt);//div where is iframe
    },
    dragStop:function(){
        $('#tempdragdiv').remove();
    }


回答3:

have you tried setting a z-index for the iframe?

var iframe=document.createElement('IFRAME');    
iframe.css('z-index', '-999');
$(div).append(iframe)
       .dialog();