Right Click Context Menu Script for iFrame
- by Ramiz Uddin
The context of the problem is related to an application which is based on single-page Ajax application which consists of three different panels (iframes).
The layout of the page is as follows:
_________________________________________________
| |
| Frame A | FRAME C
|__________________|
| |
| Frame B |
| |
| |
| |
| |
| |
| |
| |
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.
Code snippet:
var rightedge = parent.frames["FrameC"].frameElement.clientWidth-event.clientX;
var bottomedge = parent.frames["FrameC"].frameElement.clientHeight-event.clientY;
if (rightedge < 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 < 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;
Currently, we need it to work only for IE (7 and 8).
Please, help!
Thanks.