www.webdeveloper.com
Results 1 to 6 of 6

Thread: How do I open two Iframes from one link?

  1. #1
    Join Date
    Aug 2009
    Posts
    19

    How do I open two Iframes from one link?

    I plan on having a page with two iframes, one frame that has text content and one frame that has the image that corresponds with the text.

    The main iframe will be controlled by a dropdown menu so when subject is chosen the frame opens with text, this part I have done and works fine.

    My main issue is how can I get the 2nd frame to open with an image as soon as main frame is opened. I am looking for a simple script that as soon as Iframe1 opens it automatically opens Iframe2 with the corresponding image.

    someone said it will be something like this?

    <script type="text/javascript">
    function change_frames(url1) {
    window.open(url1,'InlineFrame2');
    }
    </script>

    but it just does not seem right and cannot figure out how to impliment this to the text file that Iframe1 would utilise.

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    First of all using an iframe just to show an image is (to say the least of it) unnecessary.
    The most maintainable way to do this is to have an image placeholder in your parent page:

    Code:
    <img id='myPic' src='default.jpg'>
    Then in each iframed document:

    Code:
    <script type='text/javascript'>
    
    parent.document.getElementById( 'myPic' ).src = 'relatedimage.jpg';
    
    </script>
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

  3. #3
    Join Date
    Aug 2009
    Posts
    19
    thanks for the suggestiuon, but the way i have set up the page it has 2 iframes and one is specifically for images, thats why i am looking for specific script that does that.

  4. #4
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,097
    That is a bad way for SEO BTW.
    :-(

  5. #5
    Join Date
    Aug 2009
    Posts
    19
    Quote Originally Posted by donatello View Post
    That is a bad way for SEO BTW.
    :-(

    i dont care about SEO, its just how i require this specific page to load. The page has been specifically made with 2 iframes for a reason. Once i get the script i need i will show you all what it was about so will make sense in the long run.

  6. #6
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by a01020304 View Post
    thanks for the suggestiuon, but the way i have set up the page it has 2 iframes and one is specifically for images, thats why i am looking for specific script that does that.
    The main iframe will be controlled by a dropdown menu so when subject is chosen the frame opens with text, this part I have done and works fine.
    What code are you using to do that? It should be easy to modify.

    An alternative is to have code like this in the text iframe:

    Code:
    <script type='text/javascript'>
    
     parent.document.getElementById( 'pictureIframe' ).src = 'relatedpage.htm';  
    
    </script>
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

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



Recent Articles