Link to home
Start Free TrialLog in
Avatar of dgelinas
dgelinasFlag for United States of America

asked on

Mouse Drag Resizing of Iframe

I have table data on an Iframe, which I would love to enable it to be resizable.  A reg browser window is resizable by every corner you put the mouse on when it is not maximized.  If I could get an iframe to do the same the would be wonderful.  Possibly by clicking on an object on the page and dragging..  Thanks!!
SOLUTION
Avatar of NetGroove
NetGroove

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nice touch!  That solves that problem :-)
Avatar of dgelinas

ASKER

Isn't there a way so that when you start dragging the content will drag with as well instead of after you let go of the mouse? Because with this, dragging off the screen makes the whole iframe disappear.  



function reSet(){
   w = 300;
   h = 464;
   oFrm = parent.document.getElementById('iFrame');  
   oFrm.style.width = w
   oFrm.style.height = h
}


function resizeIframe(){
if(!skip){
  var thisFrame = parent.document.frames['iframe'];                             
  var w1 = thisFrame.ButtonArea.offsetWidth+MenuDiv.offsetTop;
  var h1 = bodyStuff.offsetHeight+thisFrame.MenuDiv.offsetHeight+thisFrame.MenuDiv.offsetTop+45;      
  skip =true;         
}
 if (event.button==1){  
   if(q=='h'||q=='d') w += (event.clientX-x)/20;
   if(q=='v'||q=='d') h += (event.clientY-y)/20;
   if(w<100) w = w1;
   if(h<100) h = h1;
   oFrm = parent.document.getElementById('iFrame');            //This ends up only resizing body contents  
   oFrm.style.width = w
   oFrm.style.height = h
   parent.document.frames['iframe'].resizeTo(w,h);                //This resizes the total iframe as well
 } else {
   document.onmousemove = null;
 }
}

function reSizeStart(dir){
 x=event.clientX;
 y=event.clientY;
 q=dir
 document.onmousemove = resizeIframe;
}

function reSizeDone(){
 document.onmousemove = null;
}
Avatar of NetGroove
NetGroove

I did not understood one word what you are saying.

Please post the complete code and describe your actions and what you expect.

This is how the iframe is created.  I used your code and made one of the images located on a corner graphic of a table in the iframe to be the element which invokes the function to resize.  

function iframeOpen ( iframeUrl, iframeId ) {                      
    var iframe = document.createElement('iframe');
    document.body.appendChild(iframe);
    iframe.outerHTML = "<iframe src='"+iframeUrl+"' name='"+iframeId+"' id='"+iframeId+"' allowtransparency  frameborder='0' scrolling='no' STYLE='position:absolute; display:block; top:80; z-index:999; left:150;'></iframe>";
    if(!WindowOpened) {
    WindowOpened = true;
    TheFrameOpen = document.frames[iframeId];
    TheWindowOpen = document.getElementById(iframeId);    
    WaitForClose ();
    return TheWindowOpen;
  }
  return;
  }


Please post the complete code and describe your actions and what you expect.