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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:42:01+00:00 2026-05-18T06:42:01+00:00

I have a website that consists of one parent page. Using the lightbox-style jQuery

  • 0

I have a website that consists of one parent page. Using the lightbox-style jQuery plugin colorbox I open other pages in iFrames that float on top of the parent page, overlay style.

In the javascript code on the iFrame pages I load JSON data from Facebook. Since the data loading from facebook takes time I want to store the data I’ve loaded in a variable that lives on the parent page.

Then each time I open a new iFrame in an overlay, I want to be able to check if the parent page variable is empty or not. If it’s empty, I load the data from Facebook. If it’s not empty, I get the data from the variable on the parent page.

The only reason I want to do this is increasing performance and avoiding unnecessary calls to the Facebook API.

How do I create a solution where a javascript in an iFrame can store and access data from a variable that lives on its parent page?

I don’t have real code, but in pseudo code I’d like something like this:

function loadFacebookFriends() {
   if(parentFriendsVariable is empty) {
      Load friends from Facebook
   }
   else {
      localFriendsVariable = parentFriendsVariable
   }
}

The call to the Facebook API looks like this:

FB.api("/me/friends?fields=name,first_name,picture", function(friendsData) {
    // When this callback is executed, the data I want is
    // now in the object:
    friendsData.data
});

On the parent page my javascript code is in a jQuery document ready tag.

Thanks in advance!

/Thomas Kahn

  • 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-18T06:42:01+00:00Added an answer on May 18, 2026 at 6:42 am

    I have solved the problem. The real source of it was not accessing the variable, but an error in how and when I accessed the variables in my javascript. When I declared the variables outside of jQuery in the parent page, like this:

       var friendsCache = new Object;
    

    …it worked! In my IFrame page I can access the value like this:

       var friends = window.parent.friendsCache;
    

    So now I have a solution that looks something like this. When the user has logged in successfully with Facebook Connect, I call the function loadFriends:

    function loadFriends() {
       if (jQuery.isEmptyObject(friends)) {
          FB.api("/me/friends?fields=name,first_name,picture", renderFriends);
       }
       else {
          renderFriends();
       }
    }
    
    function renderFriends(friendsData) {
       if (friendsData != undefined) {
          if (!(jQuery.isEmptyObject(friendsData))) {
             friends = friendsData.data;
             window.parent.friendsCache = friends;
          }
       }
       // Do the stuff you want to do when the friends are loaded
    }
    

    As long as the parent page isn’t reloaded, I don’t need to load the list of Facebook friends from the Graph API. Instead I load them from my cache variable, which gives me a highly noticeable increase in performance.

    Eventhough this description was a little broader in scope than my original question, I hope someone will find it useful.

    /Thomas Kahn

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

Sidebar

Related Questions

I have a menu section on a website that consists of 2 rows with
I have a website that logs in using an STS, then gets a delegated
I have designed a website that consists of the body, a container to hold
I have a website that consists of the following areas, Home About Us Project
I have a web application that consists of two websites - one running on
I am willing to build a wiki-based website that would have some other features,
I have a website that consists mainly of a single Silverlight application. The website
I have added an MVC3 web application to an existing website that consists of
I have a website that consists of 2 applications: Front end application Backend application
I have an application that consists of a client-side application and a WebApi website.

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.