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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:17:07+00:00 2026-05-27T05:17:07+00:00

Our dev and corporate sites have a slightly different frame hierarchy. Very occasionally I

  • 0

Our dev and corporate sites have a slightly different frame hierarchy.

Very occasionally I need to reference an element in a different frame.

Unfortunately, I don’t know where that frame will be in the hierarchy. I do however know it’s id.

How can I find a frame or the specific element, when I don’t know the exact structure?

For clarification
In dev, it’s basically just a page, containing a frame. I’m in the context of the frame, and was just using window.top.document to get the document I wanted.

In prod, the nesting is different, window.top.document doesn’t work, as it is inside of two other frames.

I can’t change this structure, it’s just how our application portal works.

  • 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-27T05:17:08+00:00Added an answer on May 27, 2026 at 5:17 am

    maybe you could try traversing all the frames. you will either need to use a breadth-first or depth-first search depending on how deep the frame nesting will be. pass it the root originally.

    frameSearch(yourElementId,$("frame"));
    
    function frameSearch(elementId,frames){
          if (!(frames)) {return "element not found";}
          $.each(frames,function(){
               var $elementFound = this.find("#"+elementId);
               if ($elementFound){
                   return $elementFound;
               }
               var newFrames = this.find("frame");
               if (newFrames) {frameSearch(elementId,newFrames);}
          });
    }
    

    I’m not 100% sure of the correctness of this recursive algorithm but this is the right idea I believe.

    EDIT:

    if you need to find the topmost parent, try:

     var $currentDocument = $("document");
        while ($currentDocument.parent()){
             if ($currentDocument.find("#"+yourElementId)){
                  $yourElement = $currentDocument.find("#"+yourElementId);
                  break;
             }
             $currentDocument = $currentDocument.parent();
        }
    
        if (!($yourELement)){
            $yourElement = frameSearch(yourElementId,$("frame"));
        }
    

    this will check upwards first, then downwards if that doesn’t work

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

Sidebar

Related Questions

Our dev server was recently upgraded to PHP v5.2.13. With that upgrade we have
In our dev group we have a raging debate regarding the naming convention for
Hi on our dev environment we have show all errors, warnings and notices. I'm
I have been trying to set-up Maven for use in our dev department but
I have an odd situation with a DEV site at work. Last week, our
I have a WCF service which works perfectly when deployed in our dev and
We have a mid-sized asp.net project that we just promoted from our dev server
Our dev shop currently uses Visual SourceSafe. We all know how that could end
Our Dev team had been developing enterprise web page more than 2 years ago.
On our Dev box, our application module contains references to the file:/apps/WebSphere61/systemApps/isclite.ear/ jar files

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.