Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7565683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:13:03+00:00 2026-05-30T14:13:03+00:00

I have an iframe inside which i detect a right click and pass the

  • 0

I have an iframe inside which i detect a right click and pass the mouse event to a function in the parent. Here, (inside the parent function), i have the logic to display a custom context menu and the context menu html markup is inserted into the parent DOM. Thus is need the mouse position according to the viewport (or the parent DOM), but what i received is relative to the iframe.

I tried using offsetTop and offsetParent, but this iterated only till the body tag of the innerpage.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:13:04+00:00Added an answer on May 30, 2026 at 2:13 pm

    This is the function I used:

    // Define class that will hold Object coordinates
    function CTopLeft(i_nTop, i_nLeft) {
       this.nTop = i_nTop;
       this.nLeft = i_nLeft;
    }
    
    function GetTopLeftFromIframe(i_oElem) {
       var cTL = new CTopLeft(0, 0);
       var oElem = i_oElem;
       var oWindow = window;
    
       do {
          cTL.nLeft += oElem.offsetLeft;
          cTL.nTop += oElem.offsetTop;
          oElem = oElem.offsetParent;
    
          if (oElem == null) { // If we reach top of the ancestor hierarchy
             oElem = oWindow.frameElement; // Jump to IFRAME Element hosting the document
             oWindow = oWindow.parent;   // and switching current window to 1 level up
          }
       } while (oElem)
    
       return cTL;
    }
    

    This is from http://codecorner.galanter.net/2012/02/26/absolute-coordinates-of-element-inside-of-iframe/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form which is inside IFRAME. When user click on SUBMIT,
I have a an iframe which inside there is a video link from somwhere.
Is it legal to have an IFrame on a website which inside has an
I have a form inside an iframe which is inside a jQuery UI dialog
i have iframe inside a page, and this iframe contain a submit button which
On the webpage I have iframe, in which I display some content. I want
I have a gallery which uses Fancybox to load an iFrame inside the lightbox
I have an iFrame inside my document, which at one point triggers a custom
I'm trying to display an map inside an iframe that has a needle which
I have an AD which is basically a flash file inside an IFRAME. Unfortunately,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.