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 7631125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:16:24+00:00 2026-05-31T06:16:24+00:00

Before the question, let me preface this with the fact that I am working

  • 0

Before the question, let me preface this with the fact that I am working on a very atypical project. I am not concerned with security or cross-browser implications. I am using a custom build of the Chromium project.

My question is, if I call a function from a different namespace, how can I determine the originating namespace?

For instance, lets say I have three frames:

1. window
    -> 2. frame1 //is a child of window
    -> 3. frame2 //is a child of window

Now, lets say that some JavaScript within window has a function called doStuff(), that I give frame1 and frame2 access to by going:

var localDoStuff = top.doStuff;

Within the function doStuff, is there a way for me to determine which of frame1 and frame2 called it? i.e: If I call localDoStuff within the scope of frame1, can I get frame1‘s DOM window object within the scope of doStuff?

If I use arguments.callee.caller, it gives me the string representation of the function that called it. However, I want to get the scope in which that function was defined.

I do have access to the source of the browser if anyone has a good, directed idea of how to modify the browser in order to allow this.

Pasted from comments:
I am basically emulating an OS that runs multiple applications. Each of these applications is an iframe that has access to an API defined in the parent frame of the applications. Let’s say this API had the function requestFocus() — no arguments allowed, as defined in the API spec that I am implementing. In order to give the right iframe focus, I would have to know which iframe called the requestFocus function. I know that this is not an ideal situation — I didn’t write the API spec, unfortunately…

Thanks for your help, I know that this is a really weird question.

  • 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-31T06:16:25+00:00Added an answer on May 31, 2026 at 6:16 am

    Since different frames have different Function constructors, you may detect it like so:

    function doStuff() {
        if (doStuff.caller instanceof Function) {
            // called from top
        } else if (doStuff.caller instanceof frame1.contentWindow.Function) {
            // called from frame1
        } ...
    }
    

    However, this does not work if the function is called from top-level code in which case doStuff.caller === null.

    I’m really curious to see if anyone has a solution for that.

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

Sidebar

Related Questions

Before I ask my question, let me just say that I know very little
Let me start off by clarifying that(before you guys dismiss me), this is not
Before I ask my question, let me get this straight... This is not a
Before I start with the real question, let me just say that I might
This has been asked before (question no. 308581) , but that particular question and
I asked this question before and got a great working answer. what is the
I have looked and I could not find this question before, and it surprises
Let's make it immediately clear: this is not a question about memory leak! I
This question has been asked before mentioning the lib or includes that provides a
Before I dive into the question. Let me state that by Event Loop I

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.