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
    Feb 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    body onload method

    Hi, I'm new to javascript, have a page with an inline frame that loads a shockwave file. I want the page to load first, then the inline frame. I'm not sure how to do this.

    Would I put an onload parameter in the body tag of the page that references the file to be loaded in my inline frame? I tried several ways, including putting an <A> tag that targeted the iframe but no luck. Any suggestions would be helpful.

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    assuming that your iframe is named "iFrame", then the best way to do this would be:

    <script>
    self.onload = function() {
    self.frames['iFrames'].location = 'theFileYouWantToLoad.html';
    }
    </script>


    self is another way of saying "window". so self.onload is the same as window.onload. self.frames[] is an array of all the frames in this window. iframes count as frames, so your iframe will be here. we get hold of it, by putting it's name in the box, and then we want it's location property, which controls what url the page has loaded.

    hope that helps.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    New Coder
    Join Date
    Feb 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! Works great.


  •  

    Posting Permissions

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