Author: Real Gagnon
Author's WebSite: http://tactika.com/realhome/realhome.html
You can use a Javascript function as a bridge between the 2 frames.
[main HTML (a.html)]
<HTML><HEAD></HEAD>
<FRAMESET COLS="50%,*">
<FRAME SRC="f1.html" NAME="f1" >
<FRAME SRC="f2.html" NAME="f2">
</FRAMESET>
</HEAD>
[frame 1 HTML (f1.html)]
<HTML><HEAD>
<SCRIPT>
function toOtherFrame(a, target) {
if (target == "f1")
parent.f1.document.app1.fromOtherFrame(a);
else
parent.f2.document.app2.fromOtherFrame(a);
}
</SCRIPT>
</HEAD>
<BODY>
<APPLET CODE="app.class"
NAME="app1" MAYSCRIPT
HEIGHT=200
WIDTH=200>
<PARAM NAME="target"
VALUE="f2">
</APPLET></BODY></HTML>
[frame 2 HTML (f2.html)]
<HTML><HEAD></HEAD>
<BODY>
<APPLET CODE="app.class"
NAME="app2" MAYSCRIPT
HEIGHT=200
WIDTH=200>
<PARAM NAME="target"
VALUE="f1">
</APPLET>
</BODY></HTML>
[Java applet (app.java)]
public class app extends Applet {
TextField tf;
Button b;
String target;
public void init() {
target = getParameter("target");
setLayout(new BorderLayout());
tf = new TextField(20);
add("South", tf);
b = new Button("To other frame");
add("North",b);
}
public boolean action(Event e, Object o) {
if (e.target == b) {
// The "javascript:" protocol is supported only with Netscape browser.
// To be compatible IE4 and Netscape, it would be a good idea to use
// the netscape.javascript.* package. (this is left as a "to-do" for
// the reader!)
String js =
"javascript:parent.f1.toOtherFrame(\"" +
tf.getText() +
"\",\"" + target + "\")";
try {
getAppletContext().showDocument(new URL(js));
}
catch (Exception ex) { }
return true;
}
return false;
}
public void fromOtherFrame(String s) {
tf.setText(s);
}
}
Posted On: 7-Jul-1999