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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:25:04+00:00 2026-06-13T03:25:04+00:00

In the JavaScript for the <iframe> I need to call a function in the

  • 0

In the JavaScript for the <iframe> I need to call a function in the parent window. Both windows are from the same domain.

Is it safe to use window.parent.myFunction();?

  • 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-13T03:25:05+00:00Added an answer on June 13, 2026 at 3:25 am

    Short answer

    Yes, you can use window.parent from the same domain.

    The WhatWG specification chapter 6: Loading Web pages says:

    • iframe.parent exists
    • iframe.parent is a proxy to the DOM of the iframe‘s parent
    • Access is allowed if the origins are the same

    Really long, long answer

    I am trying to show you how you can come to this conclusion by reading the specification, while keeping in the mind: What are the characteristic traits of accessing parent from within an iframe?

    Let’s start. It’s a long text.

    1. DOM attribute parent

    WhatWG#dom-parent says about window.parent:

    The parent IDL attribute on the Window object of a Document in a browsing context b must return the WindowProxy object of the parent browsing context, if there is one (i.e. if b is a child browsing context), or the WindowProxy object of the browsing context b itself, otherwise (i.e. if it is a top-level browsing context or a detached nested browsing context).

    parent is an attribute to access something like the DOM of the parent window. However:

    • What is a browsing context?
    • What does WindowProxy do?

    Let’s continue reading.

    2. Browsing context

    A browsing context is an environment in which Document objects are presented to the user.

    WhatWG#Browsing context says:

    A tab or window in a Web browser typically contains a browsing context, as does an iframe or frames in a frameset. Each browsing context has a corresponding WindowProxy object.

    3. Window proxy

    The window proxy is an object to proxy a window object and to enforce, for example, security constraints. For a window object there can be several proxies (for example two iframes from two different domains accessing the same parent).

    WhatWG#proxy-object says:

    The WindowProxy object allows scripts to act as if each browsing context had a single Window object, while still keeping separate Window objects for each Document.

    4. Security

    We are almost there. Keep reading.

    WhatWG#security-nav says:

    A browsing context A is allowed to navigate a second browsing context B if one of the following conditions is true:

    • Either the origin of the active document of A is the same as the origin of the active document of B, or
    • The browsing context A is a nested browsing context with a top-level browsing context, and its top-level browsing context is B, or
    • The browsing context B is an auxiliary browsing context and A is allowed to navigate B’s opener browsing context, or
    • The browsing context B is not a top-level browsing context, but there exists an ancestor browsing context of B whose active document has the same origin as the active document of A (possibly in fact being A itself).

    5. Deduction

    Can an iframe access functions from its parent, if both are from the same domain? Lets deduce.

    1. parent is not the window object of the parent, but a WindowProxy.
    2. The browsing context of the iframe can access its parent, because they both have the same origin (see the first security condition above).

    You see: If you read a specification carefully, you can find answers how browsers should behave. Reading specifications is an acquired skill. It needs patience and exactness.

    However: The world is not so nice. There are browsers which do not implement specifications as well as they should. Caveat emptor.

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

Sidebar

Related Questions

We need to add a javascript element inside an iframe (its inside the same
I am working on how to call a function from an iframe and pass
i use javascript to judge a page is in a iframe: if (this !=
I have a question on javascript window management. My application opens an iframe which
I have an iframe and inside that iframe a javascript function. I would like
I need to insert an iframe into a div using javascript. I need this
I have a javascript tooltip that I'd like to call a jquery modal window
I use javascript to expand an Iframe to the size of the document it
I have a jquery function and I need to call it after opening the
I need to know how can I call the below Javascript with a button

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.