Thread: HTML frames

  1. #1
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680

    HTML frames

    Hi

    I have 2 frames, one with a button and one with some text. When I press the button in the first frame I want to change the text in the second frame.
    Code:
    main.htm:
    
    <html>
    <frameset id="mainframe" border="0" framespacing="0" frameborder="0" cols="50%,50%">
      <frame name=frame1 src="frame1.htm" scrolling="no">
      <frame name=frame2 src="frame2.htm" scrolling="no">
    </frameset>
    </html>
    
    frame1.htm:
    
    <html>
    <body>
    <script LANGUAGE="VBScript">
    Sub change_OnClick
        ' This is not working
        parent.document.all("frame2").all("frameTxt2").InnerText = "Hee hee, tickles, that does!"
    End Sub
    </script>
    
    <INPUT TYPE="BUTTON" VALUE="Click me" NAME="change">
    </body>
    </html>
    
    frame2.htm
    
    <html>
    <body><P ID="frameTxt2">...</P></body>
    </html>
    The part where I want to change the text is in bold, but that code doesn't work. Can anyone help me with this?

    Thanks in advance.

  2. #2
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    <frame name=frame1 src="frame1.htm" scrolling="no">
    <frame name=frame2 src="frame2.htm" scrolling="no">

    I think your problem lies here. You have given names to the left and right frames. Now when you want to change them, you should use the keywords you have assigned. So when you want something to load in the right frame for example, use the keyword with the name identifier.

    If you want to look at some code for this, take a look at my website, and under photos, pictures are loaded to the left, after being clikced on the right.
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Here's a working version (at least it works on my setup )
    Code:
    main.htm
    
    <html>
    <frameset id="mainframe" border="0" framespacing="0" frameborder="0" cols="50%,50%">
      <frame name=frame1 src="frame1.htm" scrolling="no">
      <frame name=frame2 src="frame2.htm" scrolling="no">
    </frameset>
    </html>
    
    frame1.htm
    
    <html>
    <body>
    <script LANGUAGE="VBScript">
    Sub change_OnClick
        window.parent.document.all("mainframe").document.frames("frame2").document.body.all("frameTxt2").InnerText = "Hee hee, tickles, that does!"
    End Sub
    </script>
    <INPUT TYPE="BUTTON" VALUE="Click me" NAME="change">
    </body>
    </html>
    
    
    frame2.htm
    
    <html>
    <body><div id="frameTxt2">This is test</div></body>
    </html>
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680

    Thumbs up

    Thanks Hammer, that also woked for me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help - C code creates dynamic HTML
    By Christie2008 in forum C Programming
    Replies: 19
    Last Post: 04-02-2008, 07:36 PM
  2. Writing an HTML Preprocessor
    By thetinman in forum C++ Programming
    Replies: 1
    Last Post: 09-17-2007, 08:01 AM
  3. Design + HTML
    By orbitz in forum C Programming
    Replies: 8
    Last Post: 11-21-2002, 06:32 AM
  4. Drop-Down Nav menu error - HTML
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 10-05-2002, 09:25 AM