Results 1 to 4 of 4

Thread: refering between pages

  1. #1
    Join Date
    Mar 2004

    refering between pages


    I have a code which displays a hidden div on the screen.
    Upon a certain action (user clicking a link), I do the following in Javascript:
    * I make that div visible.
    * I add an iframe to that div using innerHTML =

    The javascript code that I have in the page that gets loaded in the IFrame need to be able to refer to the page that launched the IFrame.
    The reason is that the javascript code in the target page will later remove that inner IFrame from the div (in the original page).

    Here is the flow:
    * User performs an action and an IFrame appears on the screen.
    * The user performs a second action and the IFrame dissapears.
    I must use an IFrame, because the content that will be displayed in the IFrame is large and I don't want to load it if it will not be needed (the user will not click the link). I use the IFrame to load it on demand.

    How can I send a valid reference of the original page to the target page that gets loaded in the IFrame?


  2. #2
    Join Date
    May 2004
    Montgomery, AL
    If I understand you correctly, you are still in the same window and you wish to remove the I-Frame from the div tag? Rather than actually removing the I-Frame from the div tag, I would dynamically set the "src" attribute of the I-Frame within the div tag instead of inserting and removing the I-Frame alltogether. Then all you need to do is make the div's style tag "display:none" or "display:block" depending on the functionallity requested.

    However, if you are refering to a different calling window, you may want to check out the window.opener properties such as one that I am using on a page of mine: "opener.location.reload(true);" This reloads the parent window from the child.

    Hope this helps you somehow...

  3. #3
    Join Date
    Mar 2004
    Once I load a page inside an IFrame, I am using that page for reference. That means that I am not longer in the original page.
    I need the ID of the original page to the page that is loaded in the IFrame.
    Once I have the ID (or some other way to refer to the original page), then I can refer to any of the DIV elements in it from the page in the IFrame

  4. #4
    Join Date
    May 2004
    Montgomery, AL
    Even though you are technically on a different "page" within the I-Frame, you are still in the same "window", and therefore should still be able to access anything in that window from your javascript in the I-Frame.

    You may need to wrap the div tag in a form so that you can reference it from the I-Frame page something like below:

    <form name="OriginalForm">
    <div id="IFrameDiv" style="display:block">
    <iframe id="MainFrame" src="SomePage.htm"></iframe>

    Then you should be able to reference the I-Frame in your Javascript something like this:

    function RemoveIFrame()

    Hope this helps, and if you know anything about Javascrip cookies, then please checkout my thread...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center