开发者

Right Click Context Menu Script for iFrame

开发者 https://www.devze.com 2022-12-23 15:47 出处:网络
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:

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:

            _________________________________________________ 
            |                  |
            | 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"].frameEl开发者_开发技巧ement.scrollTop + event.clientY;

Currently, we need it to work only for IE (7 and 8).

Please, help! Thanks.

0

精彩评论

暂无评论...
验证码 换一张
取 消