Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2006
    Location
    São Paulo, Brazil
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Calling functions in different frames

    Hi, friends!

    Take a look on the following problem:

    I have two pages: functionPage.html and executionPage.html.

    Here's the code of funcionPage.html:

    Code:
    <script>
        function setImageSrc( path, obj )
        {
            obj.src = path;
        }
    </script>
    
    <html>
    <frameset>
        <frame src="executionPage.html"></frame>
    </frameset>
    </html>

    Now, here's the code of executionPage.html:

    Code:
    <script>
        window.onLoad = parent.frames.setImageSrc( "/images/someImage.gif" document.getElementById("image") );
    </script>
    <html>
        <body>
            <img src="" id="image" />
        </body>
    </html>

    As you guys can see, I have a main page that contains the funcion setImageSrc(), and inside this page I have a frame that loads the page executionPage.html.

    Here's the problem: when I call the instruction parent.frames.setImageSrc(), I DO NOT want to reffer to an image positioned in the functionPage.html. I want that he reffers to the image stored in executionPage.html!!!
    But calling funcions using parent.frames it seems that I cannot do this.

    Is there another way that i could call a function with parent.frames, but reffering to elements of the page that is calling the function?

    Or I have to make an include? I do not want to do it.... but I'm being forced to use it, i guess.

    Anyone have an idea??

    Thanks for the help, folks!
    ----
    As coisas mais simples são as mais importantes.
    ---------
    Thompson M1A1: D-Day
    ----------------

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    window.onload = function(){
      if (parent.setImageSrc) {
         parent.setImageSrc("/images/someImage.gif", document.getElementById("image"));
      }
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Mar 2006
    Location
    São Paulo, Brazil
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks!
    ----
    As coisas mais simples são as mais importantes.
    ---------
    Thompson M1A1: D-Day
    ----------------


  •  

    Posting Permissions

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