More on Passing data using a Frameset

Question: I'm just looking at your javascript tutorials about passing variable by using frameset, and I'm a bit confused the way it is handled. Could you give an example of that?
thanks a lot
Dung Duc Hoang

Answer:The way that you pass variables using a frameset is that you define the fields in a javascript to the frameset definition page rather than in any of the pages that you are going to reference the field from. This code looks just the same as you would normally use to define the field except that instead of the code being in the page where it will be used it is in the frameset definition. For example if you have a field called cust_details that you want to pass between the pages on your web site you first define it in the javascript attached to the frameset definition page as follows:

var cust_details = '';

This field now exists for as long as your visitor remains within your frameset.

To reference the field from javascripts in your individual pages you just need to add parent. onto the front of the name so in the javascript on a page where you want to assign a value to cust_details you might include the statement:

parent.cust_details = 'value to be assigned';

On a different page where you want to display the content of this field you would have a javascript containing a statement such as:


An alternate way of doing this is to place all of your javascripts in functions and attach them to your frameset definition page. For example:

function set_cust(val) {
  cust_details = val;

and then just include the call to the function from within the individual page as follows:

onclick='parent.set_cust(\'value to be assigned\');'

I hope that this helps you in working out how to do what you want.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow