Results 1 to 9 of 9

Thread: Changing the src of a frame using Javascript (newbie q)

  1. #1

    Thread Starter
    Hyperactive Member CaptainPinko's Avatar
    Join Date
    Jan 2001
    Location
    London, Ontario, Canada
    Posts
    332

    Changing the src of a frame using Javascript (newbie q)

    I have two frames: a main body frame, and a bottom frame with buttons that are used to navigate amongst the pages. I want to make it so that when you click on a button in the button frame it will change the contents of the main frame. The frames are 'fraMain' and 'fraNavig'.
    "There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein

    If you are programming in Java use www.NetBeans.org

  2. #2
    scoutt
    Guest
    set the target to the frame you want,
    e.g. <a href="file.html" target="fraMain">

    if this is not what you are after, can you show some code you are using?

  3. #3

    Thread Starter
    Hyperactive Member CaptainPinko's Avatar
    Join Date
    Jan 2001
    Location
    London, Ontario, Canada
    Posts
    332
    I know how to do it in HTML but I was wondering if could do it in JavaScript.
    basically the contents of fraNavig are bunch of

    <input type = "button" name = "butMain" value="Main" onClick="">

    It is in the onClick that I want to insert the change frame source. I need to do it in JavaScript for reasons I don't feel like explaining.
    "There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein

    If you are programming in Java use www.NetBeans.org

  4. #4
    scoutt
    Guest
    sure I understand. you could do something like this
    Code:
    function load() {
      parent.frames.top.location = "main.html";
    }
    
    onClick="load()">
    see if that works

  5. #5

    Thread Starter
    Hyperactive Member CaptainPinko's Avatar
    Join Date
    Jan 2001
    Location
    London, Ontario, Canada
    Posts
    332
    I don't see the part where I specify that I want this new page opened in "fraMain"...
    All that code did was open up a pagethat replaced my frames page, but I just want to open the page into an existing frame
    "There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein

    If you are programming in Java use www.NetBeans.org

  6. #6
    scoutt
    Guest
    sorry I thought it would go into the parent. ok try adding a .parent to the code, so it would be

    parent.parent.frames

  7. #7
    Member
    Join Date
    Aug 2000
    Location
    London, ON
    Posts
    40
    Thnx for the help Scoutt, but I got it now. I took a look at an e-book and kinda hacked it out.
    For anyone looking for good JavaScript info go:
    http://home.netscape.com/eng/mozilla...ok/javascript/

    For anyone who was following along here is the answer:

    parent.window.XXXX.location = "http://YYYYY"
    where XXXX is the frame name and YYYYY is the URL that you want to go to.
    Visual Basic 6 Professional Edition
    Captain Pinko

    also:
    Turbo Pascal, Turing, QBasic

  8. #8
    scoutt
    Guest
    oh crap, my bad. I see what I did

    Code:
    function load() {
      parent.frames.fraMain.location = "main.html";
    }
    sorry that should work.

  9. #9
    scoutt
    Guest
    ya i forgot to change the name of the frame. I just took out of one of my pages and forgot to change it. I will also take a look at that page. thanks for the link.

Posting Permissions

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



Click Here to Expand Forum to Full Width