Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Thanked 0 Times in 0 Posts

    Referencing Main Page from iFramed Page

    Hello, I have a script which works from my main page, but I need to embed it also into an iframed page, and have it affect the main page from there as well. Let me try to explain...

    In my main page, I have the following iframes:

    <iframe id="main">
    <iframe id="player">
    <control buttons embedded on main page, along with the iframes>

    The default source of "main" is page A, which is a frameset of pages B and C. In page B, I want to embed the same controls I have on the main page, and have them affect the main page from there. Here's the controls script from the main page - it works from that page - a resizing onClick of the "player" iframe:

    <script language="JavaScript">
    function resizeIframe(iframeId, iframeHeight, iframeWidth)
    if (iframeWidth>0)
    if (iframeHeight>0)

    <a id="widenButton" onclick="resizeIframe(player', 420, 720)return false;">Enlarge Player</a>

    How would I put the widenButton in that back page and still have it affect the front page?

    Thanks in advance for any help,
    Miz Parker

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,746 Times in 4,708 Posts
    <a id="widenButtonInIframe" 
        onclick="parent.resizeIframe('player', 420, 720);return false;"
    >Enlarge Player</a>

    No, you don't need to copy the JS code to the IFrame page.

    NOTE: This ONLY works if the iframe src= is from the same domain as the main window. But that is true for ANY technique you might use.


    Posting Permissions

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