-
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.
-
<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.
-
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>
-
Thanks Hammer, that also woked for me.