[Prev][Next][Index][Thread]

Interframe communication



Here is how I am handling interframe communication at
http://www.siteseer.cape.com/yourpage/

All the state is held in a form in a single distinguished frame.
The script in this page provides a set of update methods for the state.
I probably should have written accessor methods, but I didn't.
This frame must be loaded before any other frame wants the variables.
To accomplish this, the other frames are initially targeted at stub pages,
then the frame holding the state is loaded, and it navigates the other frames
to the correct location.

The other frames that manipulate and refer to the state can make
use of the state variables at this point.  When a frame
updates the state, the change method for the state element is invoked,
and this causes changes in the other frame that refers to this page.
The code is ad hoc, but it illustrates the effect. The primary advantage of
this method is that state from multiple pages is in a central location where
it can persist. 

I hope that the liberal use of ActiveX and VBScript doesn't obscure the
intent of the code.  There is a significant problem here in that all this code
is in a very referentially opaque and imperative style.  This problem
stems from the underlying imperative model.

Here is an example of what happens.  Feel free to extend this example.

Contents of defpage:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HEAD
   ><TITLE
       >Example</TITLE
   ></HEAD>
<SCRIPT Language="VBScript">
<!--
Option Explicit

Sub Update_Name ()
    parent.previewframe.preview_alx.Name.Caption = layoutform.Name.Value
End Sub

Sub Set_Name (szName)
    layoutform.Name.Value = szName
    Update_Name ()
End Sub

Sub init ()
    parent.previewframe.navigate ("preview.htm")
End Sub

-->
</SCRIPT>
<BODY BGCOLOR="#000000" OnLoad="init"
><FORM ACTION="/cgi-bin/form_submit"
       TARGET="_top"
       METHOD="POST"
       NAME="layoutform"
><INPUT TYPE="HIDDEN" NAME="Name"        VALUE="Your Name Here"
></FORM
></BODY
></HTML>

The preview frame would look like this:

<SCRIPT Language="VBScript">
<!--
Option Explicit

Sub demo_OnLoad ()
    Name.Caption   = parent.pageformframe.layoutform.Name.Value
End Sub

-->
</SCRIPT>
<DIV ID="demo" STYLE="LAYOUT:FIXED;WIDTH:400pt;HEIGHT:375pt;">
    <OBJECT
        CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0"
        ID="Name"
        STYLE="TOP:0pt;LEFT:5pt;WIDTH:256pt;HEIGHT:34pt;ZINDEX:3;">
        <PARAM NAME="ForeColor"           VALUE="16777088">
        <PARAM NAME="Size"                VALUE="9031;1199">
        <PARAM NAME="VariousPropertyBits" VALUE="268435475">
    </OBJECT>
</DIV>

And the control frame looks like this:

<SCRIPT LANGUAGE="VBScript">
<!--
Option Explicit

Sub Name_Change ()
    parent.pageformframe.Set_Name (Name.Value)
End Sub

Sub ctl_OnLoad()
    Name.Value         = parent.pageformframe.layoutform.Name.Value
End Sub

-->
</SCRIPT>
<DIV BACKGROUND="#000000"
     ID="ctl" 
     STYLE="LAYOUT:FIXED;WIDTH:399pt;HEIGHT:100pt;">
<OBJECT
        CLASSID="CLSID:8BD21D10-EC42-11CE-9E0D-00AA006002F3"
        ID="Name"
        STYLE="TOP:32pt;LEFT:16pt;WIDTH:190pt;HEIGHT:16pt;TABINDEX:10;ZINDEX:29;">
        <PARAM NAME="FontCharSet"         VALUE="0">
        <PARAM NAME="FontPitchAndFamily"  VALUE="2">
        <PARAM NAME="FontWeight"          VALUE="0">
        <PARAM NAME="MaxLength"           VALUE="64">
        <PARAM NAME="Size"                VALUE="6703;564">
        <PARAM NAME="VariousPropertyBits" VALUE="746604571">
    </OBJECT>
</DIV>