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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:04:02+00:00 2026-06-16T05:04:02+00:00

I have a javascript like the following on my main page: It just defines

  • 0

I have a javascript like the following on my main page: It just defines a variable

test1 = function(){
var bla= "bla";
}

In my iFrame, I have another javascript which only produces an alert like the following

alert(parent.test1.bl);

Unfortunately, the alert window appears but the content says “undefined”. How can I read a variable from within a function in the parent window?

The funny part is that if I execute the alert at the parent window and call only the function from within the iFrame, the alert box pops up and the message is included. But it seems that it is not possible to read a variable from the parent.

  • 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-16T05:04:03+00:00Added an answer on June 16, 2026 at 5:04 am

    Functions haven’t properties, objects have. So you’ve to instantiate test1() before trying to use its properties.

    test1 = function(){
        var bla= "bla";
        this.bl ="notbla";
    }
    
    alert(new test1().bl);
    

    Notice the usage of the keyword this here, which refers to the newly created object, and makes bl a property, that can be read outside of the function. bla declared with var can’t be seen outside of test1(), unless you won’t create another property like this.bl = bla;

    The “funny part” of your question really is unclear, definitely your alert() will show undefined, no matter where it’s invoked.

    Functions and Objects at MDN.

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

Sidebar

Related Questions

I have the following javascript: $.post(/Authenticated/DeletePage/ + PageId); showStatus(Page deleted..., 10000); I would like
I have used Javascript onlaod like this: function check() { var pic = new
Let's say I have some simple Javascript like: <script> var hello = function(){ alert(Hello
I have a JavaScript data structure like the following in my Node.js/Express web app:
I have the following JavaScript code which I like to convert to jQuery but
In my javascript file I have the following line: <div id=mygraph style=width:200px;height:100px;></div> I'd like
I have a javascript object like so: var object = [{ id: 1, title:xyz
Assuming I have a JavaScript function like this... function Object1() { this.var1; this.var2; this.var3;
let's say I have a simple javascript like so: $(document).ready(function(){ if(login == 1) {
Given that I have a JavaScript section in my HTML page like : <script

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.