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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:51:06+00:00 2026-06-09T20:51:06+00:00

I have an Iframe inside of a page that has the src set to

  • 0

I have an Iframe inside of a page that has the src set to a file on the same local machine (not cross domain).

So I have a page that looks like this:

<html>
 <head/>
 <body><iframe id="something" src="somepage.html"/></body>
</html>

Inside of the iframe there is some contents

    <html>
    <head/>
     <body>
      <li>
        <ul>stuff</ul>
      </li>
     </body>
    </html>

My question is, I have a variable (in my index page) that is currently pointing to the element var element = <ul>stuff</ul> which is inside of the iframe.

From this variable I want to be able to access the parent iframe and get the id ‘something’.

I have been attempting some jquery using find with no luck

$(element).find('iframe')

And I am wondering where I am going wrong… I have googled other solutions but they are all related to being outside of the iframe looking in, I guess I am inside looking out! is there anyone else out there that could help shed some light?

  • 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-06-09T20:51:08+00:00Added an answer on June 9, 2026 at 8:51 pm

    It seems to be very difficult to find the id of the iframe element without something like its name.

    But supposing you know the name of the html file in the iframe (“somepage.html”), which seems natural, you can do this to get the element containing the iframe in the parent document :

    var $matching = $(parent.document).find('iframe').filter(function(){
        var srcTokens = this.src.split('/');
        return srcTokens[srcTokens.length-1]=='somepage.html';
    });
    

    Here’s the “somepage.html” file I used to test, logging the id in the console :

    <html>
        <head>
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
            </head>
         <body>
          <li>
            <ul>stuff</ul>
          </li>
          <script>
              var $matching = $(parent.document).find('iframe').filter(function(){
                  var srcTokens = this.src.split('/');
                  return srcTokens[srcTokens.length-1]=='somepage.html';
              });
              console.log($matching.attr('id'));
              </script>
         </body>
        </html>
    

    EDIT : as was seen by Serjio, it’s possible to use location.href if you don’t know the name of the html file.

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

Sidebar

Related Questions

i have one iframe on my page which has a different domain to that
I have a page with an iframe. Inside the iframe is code (that I
I have an iFrame which has it's source set to another aspx page. The
I have an iframe that displays a php page inside it when submitting a
I have an iframe on my page, and inside that iframe I execute code:
On my page, I have an iframe tag that I control. The iframe src
I have an iframe that loads a page inside it.. when a link is
I have an IFrame inside my 1st page that loads another page which I
I have a Help page, help.php that I am loading inside an iframe in
I have an iframe embedded inside a fan page of FB, and I want

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.