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

  • Home
  • SEARCH
  • 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 3316306
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:27:14+00:00 2026-05-17T22:27:14+00:00

Lets say I have a page on the same domain that I put inside

  • 0

Lets say I have a page on the same domain that I put inside an iframe. In the iframe, I have added data to an element, something like this:

HTML

<div id="data"></div>

Script

$('#data')
    .data('test1', 'this is test data 1')
    .data('test2', ['John', 'Smith'])
    .data('test3', {
        alert1: function() {
            $('#data').append('test3: successful<br>');
        }
    })

Now once this page is in an iframe, I know I can access the element as follows:

$('#frame').contents().find('#data');

But when I try to get the data from that element, it’s always undefined.

$('#frame').contents().find('#data').data('test1'); // shows up as undefined

I know jQuery stores data() internally in a cache object, but I don’t know how to access it from outside that document. I set up this demo to display my problem. Click the “Get Frame Data” button to see the results.

I would appreciate any input 🙂

  • 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-17T22:27:15+00:00Added an answer on May 17, 2026 at 10:27 pm

    You need to get the cache element from that window’s jQuery object, like this:

    var windowjQuery = $('#frame')[0].contentWindow.$;
    var f = $('#frame').contents().find('#data');
    

    Then to get data, use $.data(), like this:

    windowjQuery.data(f[0], 'test1')
    

    You can test out your updated/working demo here.


    What this is really accessing is:

    var key = f[0][frame.contentWindow.$.expando];
    var dataItem = frame.contentWindow.$.cache[key]["dataKey"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say that I have a header user control in a master page, and
Let's imagine that I have something like this: <html> ... <div> <iframe src=test.html hash=r4d5f7></iframe>
Let's say I have a web page that currently accepts a single ID value
Let's say you have a aspx page that does not rely on session, but
Lets say I have a simple ecommerce site that sells 100 different t-shirt designs.
Let's say I have a page that refers to a .js file. In that
Let's say I have a page called display.php and the user is viewing display.php?page=3
Let's say I have four tables: PAGE , USER , TAG , and PAGE-TAG
Let's say I have an aspx page with this calendar control: <asp:Calendar ID=Calendar1 runat=server
I have two websites, let's say they're example.com and anotherexample.net . On anotherexample.net/page.html ,

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.