title: Right Click Context Menu Script for iFrame
body: <p>The context of the problem is related to an application which is single-page Ajax application. The layout of the page consists of three different panels (iframes) as follows:</p>
  
  <pre><code>            _________________________________________________ 
              |                  |
              | Frame A          |       Frame C
              |__________________|
              |                  |
              | Frame B          |
              |                  |
              |                  |
              |                  |
              |                  |
              |                  |
              |                  |
              |                  |
  </code></pre>
  
  <p>The problem is with the context menu (right-click menu) in Frame C. The position of the context menu is not perfectly positioned with the mouse click. Particularly, if you drag and increase the size of the Frame C window.</p>
  
  <p>Code snippet:</p>
  
  <pre><code>    var rightedge = parent.frames["FrameC"].frameElement.clientWidth-event.clientX;
      var bottomedge = parent.frames["FrameC"].frameElement.clientHeight-event.clientY;
      if (rightedge &lt; document.getElementById('Menu').offsetWidth)
          menuCoorX = parent.frames["FrameC"].frameElement.scrollLeft + event.clientX - document.getElementById('Menu').offsetWidth;
      else
          menuCoorX = parent.frames["FrameC"].frameElement.scrollLeft + event.clientX;
      if (bottomedge &lt; document.getElementById('Menu').offsetHeight)
          menuCoorY = parent.frames["FrameC"].frameElement.scrollTop + event.clientY - document.getElementById('Menu').offsetHeight;
      else
          menuCoorY = parent.frames["FrameC"].frameElement.scrollTop + event.clientY;
  </code></pre>
  
  <p>Currently, we need it to work only for IE (7 and 8). </p>
  
  <p>Please, help!
  Thanks.</p>