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

  • Home
  • SEARCH
  • 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 4044332
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:14:28+00:00 2026-05-20T13:14:28+00:00

I’m working on a browser automation framework that, among other browsers, drives IE. As

  • 0

I’m working on a browser automation framework that, among other browsers, drives IE. As such, I need to get the screen coordinates of elements the user wants to interact with. The primary method we use to get these coordinates is by using getBoundingClientRect(). The problem is that in IE, these coordinates are always given relative to the top-left corner of the enclosing document. If the element is in a frame/iframe, this may not be the screen coordinates of the element relative to the top-left corner of the browser window.

I use COM via C++ to drive the browser, though I am able to execute JavaScript via that C++ driver layer. I am also driving it out-of-process, which means I am not executing within a Browser Helper Object (BHO, or IE add-in). Moving to a BHO is not an option for this project. Outside of working with IE 6, 7, 8, and 9, I don’t have to worry about cross-browser compatibility for whatever method I can find that works. Using jQuery or similar really isn’t an option for me, but if there is a solution that uses a JavaScript library, I may be able to reverse-engineer a solution that is acceptable for use within the project.

Here are some of the things I’ve tried so far:

  • Use element.ownerDocument.parentWindow.frameElement within JavaScript. This will fail if the containing document and the document within the frame are in different domains.
  • Use IHTMLWindow4::get_frameElement() on the window containing the element within a frame. This should be the C++ equivalent of the JavaScript method above; however, it returns E_NOINTERFACE when I attempt to use it.
  • Use IDisplayServices::TransformPoint() to convert the coordinates of the element top-left corner to a different frame of reference. This does not appear to work cross-process.

How can I find or calculate the screen coordinates of an HTML element relative to the upper-left corner of the browser window, when the target element may exist within a frame or iframe?

  • 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-20T13:14:29+00:00Added an answer on May 20, 2026 at 1:14 pm

    The correct approach for this project is to get the document containing the frame or iframe element and looping through the set of frames in that parent document until you find the proper frame. Once there, you can get the or element using the document.parentWindow.frameElement(), and can calculate the location of the containing element from there. The actual code solving the problem can be found in Element::AppendFrameDetails() at this link.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a

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.