Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Autumn Leaves Script invoked from diff frame

  1. #1
    Join Date
    Jul 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Autumn Leaves Script invoked from diff frame

    Autumn Leaves
    http://www.dynamicdrive.com/dynamicindex3/leaves.htm

    I would like to invoke this script from within an iframe and have it use the entire page, i.e., the parent to the iframe. My idea is to have the falling object images cover the entire browser window and change to a different image when the iframe is reloaded.

    Thank you for your assistance.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Wherever you see "document," change it to "parent.document".
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It is unlikely that will work. What is likely to work is to put the script on the parent page. Remove the line:
    Code:
    window.onload=fall
    from the script. Then on the page that displays within the iframe make a small script:
    Code:
    <script type="text/javascript">
    window.onload=function(){
    parent.fall();
    }
    </script>
    Changing the images depending upon the page loaded in the iframe is a bit trickier. My approach would be to modify the script so that the original images are represented by image objects and add to the main script on the parent a function to change the images with a single command issued from the child frame. Let's get the first part (activating from the iframe document) working first.
    Last edited by jscheuer1; 07-31-2005 at 04:51 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I think it would work... I had a quick look at the code and I saw no real reason why not. You'd need to change window to parent, as well.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jul 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you both for your quick replies! I was not able to get Twey's solution to work to invoke the script from the iframe - but it could have been a typo on my part. Instead, I used jscheuer1's idea but simply added onload=parent.fall(); to the body tag of the page displayed in the iframe. I will let you know if I am successful changing the images. I was thinking maybe I could change the parent's preloaded images from the iframe, something like: parent.Image0.src=parent.grphcs[0]="FLleafbrnlrg.gif";
    etc.


    One more question - how would I "uninvoke" the falling leaves instead. For example, I load a new page into the iframe and want to turn off the falling objects altogether.

    Thanks again for your help.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Twey,

    It won't work because the script uses document.write. Once you change document.write to parent.document.write and execute it from the iframe page, it wipes out the parent document, including the iframe containing the script.

    codymaxx,

    I don't think your approach to changing the graphics will work because once the script is loaded and displaying the leaves, it no longer relies upon the the array called 'grphcs' to determine what the falling images are.

    I've got a little demo working here. I also had to make the falling images invisible to begin with because, as codymaxx probably sees, they stack up in the upper left corner otherwise, until set in motion by the loading of the iframe page. I've turned off this effect before. It requires giving this time out a variable name:
    Code:
    setTimeout('fall()',20);
    and then later clearing it while, at the same time making the images invisible, to stop the effect. Once I add that in, I will put up a live demo.
    Last edited by jscheuer1; 07-31-2005 at 06:50 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, here's a demo. Unfortunately the server doesn't allocate much bandwidth to these 'personal pages' so be patient at first if nothing happens when you click on the link above and when you click on the buttons and links on the demo. Once you've had it through its paces, everything should be cached and work as it would on an average speed server.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Jul 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you, John! That's exactly what I wanted.

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ah, I see. Whoops.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Jul 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I've implemented John's solution and it works great in IE. However, in Netscape and FF, the script causes bottom and right scrollbars to appear and disappear as objects drift off the screen and thus the window contents appear "jumpy" and difficult to read. Is there a way to eliminate this problem (which exists with the original script also)? Thanks!

Bookmarks

Posting Permissions

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