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 2 of 2

Thread: iframe onload

  1. #1
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    iframe onload

    I am not very familiar with JavaScript, but I am trying to use iframes.

    I have a gallery as part of my website, and I am using iframes to change the large photo that is currently showing, as well as to change a secondary nav bar. Everything is working for the gallery, except when I first open it the iframes are empty.

    I want to be able to click on a link from my regular website and open it in the gallery in the iframe. I figured I needed to add an onload event to the link. To make it more difficult, I want the link to open 3 specific things in 3 iframes in the gallery. I can't have the gallery always open with the same 3 images showing because they need to change depending on which link is used to open the gallery.

    Check it out at ckdesigns.biz Click on "Gallery" and you will see the empty iframes. If you then click on "Puppies" in the Gallery it will show one of the iframes, then click on "Bill" and it will show the other 2. (These are the only links for iframes I have working right now.)

    Thank you so much for the help!!!

  • #2
    New to the CF scene
    Join Date
    Dec 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile I Figured It Out!!!!!

    After days and days of googling my problem, I finally tried something that worked, and it was all too simple!

    This is what I ended up putting in the body tag of my gallery page that has the iFrames on it:

    <body onload="iFrameName.location='iFrameContent.html'">

    Where "iFrameName" is the name of the iFrame I am targeting, and "iFrameContent.html" is the .html file I want to initially open in the iFrame when the gallery page is first opened. If you have multiple iFrames you don't want empty when the page opens, the code would look like this:

    <body onload="iFrameName1.location='iFrameContent1.html', iFrameName2.location='iFrameContent2.html'">

    In my case, I need the gallery page to open with different things showing in the iFrames, depending on which link took you to the gallery page. So...what I will do is create multiple gallery "start" pages and change the <body onload=...> tag.

    I hope this helps someone. I found a lot of people with the same problem and no responses, so here you go!

    You just need to make sure that the .html file you want to open in the iFrame has the correct path according to whatever page your iFrames are on.


  •  

    Posting Permissions

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