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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:22:52+00:00 2026-05-26T11:22:52+00:00

My iframe has a variable. I want to access document holding the iframe and

  • 0

My iframe has a variable. I want to access document holding the iframe and play with a variable defined in javascript.

e.g.

<html>
<head>
<script>var a=0;</script> 

</head>
<body>

<iframe id=playmate src="document2.htm" height="150px" width="100%" scrolling="no"       
 border="0" frameborder="0"></iframe>>

</body>
</html>

Now in document2.htm I have a script that needs to access and manipulate var a. Can I access it directly, use jquery or plain vanilla javascript?

Its not a cross domain iframe. Promise. Same domain. Want them to play together nicely.

In the past I used to do this by getting the variable to insert a hidden input from one document into the other, but with the advent of ajax and what what I was wondering if I could just manipulate it.

So previously would write a function into the head of document, where if my var a did something, my hidden input in playmate document2 would update. Then document2 could just use hidden input and everyone was happy. When document2 played with the variable it would insert the result into hidden input in the holding document, and var a could then play properly with the new result.

I want to know if its now possible for playmate document2 to play with var a in the script without having to do hidden input. Would be very exciting.

Anyone got any ideas how to go about?
I am using jquery if that would make it easier.

I tried using this script in document2:

 var c=window.document.parent.a;

But when I then output var c it tells me its notanumber. Bother. Please help. Or must I do my hidden input method.

  • 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-26T11:22:53+00:00Added an answer on May 26, 2026 at 11:22 am

    You were close. It’s actually:

    window.parent.a
    

    (window.parent returns a window object, and variables are children of the window object not the document object.)

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

Sidebar

Related Questions

Suppose a HTML document has a iframe. Using javascript,I want to detect ,on load
Does the IFRAME's onload event fire when the HTML has fully downloaded, or only
Page A has iframe B. In iframe B, I have a var store a
I have a script that write a iframe into the page. I want to
Basically, I have an iframe embedded in a page and the iframe has some
I have a page that has an iframe From one of the pages within
I have a page which has an Iframe. In that Iframe, there are six
I have a div and an iframe on the page the div has z-index:
Is there anyway to unload a page that has been loaded inside an iframe?
I am writing an iframe based facebook app. Now I want to use 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.