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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:48:24+00:00 2026-05-14T00:48:24+00:00

I have a number of iframes calling a function in my main page. Is

  • 0

I have a number of iframes calling a function in my main page. Is there a way to find out the ID of the iframe which called the function?

There are all part of same domain so that should not be an issue.

Thank you for your time.

  • 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-14T00:48:24+00:00Added an answer on May 14, 2026 at 12:48 am

    The most common way is to have the control pass itself to the function

    <script>function doClick(e){ alert('id = ' + e.id); }</script>
    <span id=test onclick="doClick(this)"> click here</span>
    

    Another way would be by using the:

    event.srcElement
    

    As documented here.

    A third way but not as reliable would be by using:

    document.activeElement.name
    

    The latter is not the best approach.

    In my personal opinion I’d go with the first one, as it will work 100% of the time, and won’t give you browser issues.

    UPDATE
    To get the current iframe’s id (assuming you don’t have nested iframes on the same page), you can simply use:

    this.document.getElementsByTagName('body')[0]​.id
    

    And then simply pass it along with the call to your function. just make sure the body has the same ID as your iframe for example.

    Let me know if it helps you.

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

Sidebar

Related Questions

I have a single page application which create and remove a number of iframe
I have an intranet web application which uses iframes. The outer web-page has a
I have a web page with a number of iframes, including 3rd party iframes
I have a page with a dynamic number of iframes. window.print() has to be
Because of several iframes, XUL browser elements, and so forth, I have a number
I have a page with several iframes. One of this iframes has a page
Hi I have the following iFrame and I would like to get the number
I have a form which submits to an iFrame (this is a common approach
I have a website which I have embedded lightview to bring up an iframe
Folks, I have a DIV that contains a number of IFrames (long story). The

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.