Right Click Context Menu Script for iFrame

Posted by Ramiz Uddin on Stack Overflow See other posts from Stack Overflow or by Ramiz Uddin
Published on 2010-03-16T11:57:09Z Indexed on 2010/03/16 12:06 UTC
Read the original article Hit count: 419

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about ie

Related posts about iframe