• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

10. Page Navigation Techniques > 10.5. Passing Data Between Pages Via Frames

Passing Data Between Pages Via Frames

NN 2, IE 3

Problem

You want to move user-influenced data from one of your pages to another without server intervention while using a frameset.

Solution

The window object representing the frameset remains fixed while documents move in and out of child frames. This top window is capable of storing JavaScript data of all types in global variables. Use an onunload event handler of a framed page to preserve the data in a global variable of the frameset’s window. In the following example, a string from a text input element is stored in a global variable called userName:

<script language="JavaScript" type="text/javascript" >
function saveData( ) {
    top.userName = document.forms[0].userName.value;
}
</script>
...
<body onunload="saveData( )">

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint