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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:20:23+00:00 2026-05-30T11:20:23+00:00

I have an HTML page embedded inside another page. Now I would like to

  • 0

I have an HTML page embedded inside another page. Now I would like to make visible a div in the parent document, by clicking on a link in the embedded document. I know how to make a div visible (I’m using jQuery), but how do I check if somebody clicked on a link in an embedded document?

I have a situation like this:

index.html

<div id="box1">Text</div> 

<div id="wBox1">
  <a href="#" class="hideLink">[X]</a>
  <object id="objPage" name="foo" type="text/html" data="box.html"></object>
</div> 

<div id="wProdBox1">
  <a href="#" class="hideLink">[X]</a>
  <object id="objPage2" name="foo" type="text/html" data="box1.html"></object>
</div> 
<script type="text/javascript"> 
  $("#box1").click(function () { 
    $("#wBox1").show("slow"); 
    $("body").addClass("scroll"); 
  }); 

  $("#product1").click(function () { 
   $("#wProdBox1").show("slow"); 
   $("body").addClass("scroll"); 
  }); 
</script> 

And in box.html

<div id="product1">Text box</div>

So I need to open a div in index.html by clicking on div id=product1 in box.html.

  • 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-30T11:20:24+00:00Added an answer on May 30, 2026 at 11:20 am

    Interaction between separate browser windows is quite different from interaction between a document and its embedded documents. As such my original answer won’t be much help. I’ve updated my answer below to apply to your situation. I’ve also updated your question title to better reflect what you are trying to do.

    The following techniques will work to bind a click event in an embedded document:

    Bind from the embedded document, and reference the parent document with top.document:

    $(function () {
        $("#product1").click(function () {
            $("#wProdBox1", top.document).show("slow");
        });
    });
    

    Or, bind from the parent document, and reference the embedded document with document.foo.contentDocument:

    $(window).load(function () {
        $(document.foo.contentDocument).ready(function () {
            $("#product1", document.foo.contentDocument).click(function () {
                $("#wProdBox1").show("slow");
            });
        });
    });
    

    But… That’s the happy path and works in modern browsers. Sadly, we have some difficulties to work out in order to support IE8 and IE7:

    1. The second technique doesn’t work in IE7 because it doesn’t support contentDocument.
    2. The first technique doesn’t work in IE8 and IE7 because the embedded document thinks it is the top window. Ie, window.top === window.

    To fix issue 1, it’s not too bad. If document.foo.contentDocument doesn’t exist, we use document.foo.parentWindow.document:

    var boxDoc = document.foo.contentDocument || document.foo.parentWindow.document;
    $(boxDoc).ready(function ()
    {
        $("#product1", boxDoc).click(function (e)
        {
            $("#wProdBox1").show("slow");
        });
    });
    

    To fix issue 2, We need to add some code to the parent document to tell the embedded document about the parent window.

    boxDoc.parentWindow.parentDocument = document;
    

    But… Chrome and FireFox don’t support parentWindow. To get the document’s window, you have to use defaultView, and IE7 doesn’t support defaultView. So, our code becomes:

    var boxWin = boxDoc.defaultView || boxDoc.parentWindow;
    boxWin.parentDocument = document;
    

    Then, we have to reference parentDocument in the embedded document:

    $("#wProdBox1", parentDocument).toggle();
    

    Here’s a working cross-browser demo that uses both techniques.

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

Sidebar

Related Questions

Is it okay to have an HTML document embedded inside the body tag of
I have HTML page where windows media player is embedded. It works very well
I have a plain html web page with an embedded flash object. Based on
If I have a frame embedded into a html page. The page connects through
I have a music player swf embedded on an html page. Is there any
I have some html content stored in a database field. I would like trusted
I have a swf file that's embedded in a html page, and I have
I have an HTML page which contains an Object tag to host an embedded
I have a working webpage which just displays external html files inside a div
I have embedded the signed applet in following html page, <input type=hidden name=xmldata id=xmldata

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.