Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1499 How can I pass the contents to be loaded into a "generic" frameset definition?

You are here: irt.org | FAQ | JavaScript | Frame | Q1499 [ previous next ]

From links on a splashscreen load designated files into a generic frameset.

You can try the following code:

<!--Put this script in the frameset document-->

<script language="JavaScript"><!--
var input = location.search.substring(1);
var separator = "&";

//set up frameset
document.write('<frameset cols="20%,*" rows="20%,*" frameborder=1>');
// put the logo page in (this is a static page)
document.write('<frame src="logo.htm">');

// split the passed parameter list (by the ampersand)
// and store into the array "arrayOfStrings"
arrayOfStrings = input.split(separator);

// loop thru the array "length of the array" number of times
// and write the dynamic frames sets and the associated pages
for (var i=0; i < arrayOfStrings.length; i++) {
  document.write('<frame src="' + arrayOfStrings[i] + '.htm">');
}

//  close off the frameset declaration
document.write('<\/frameset>');
//--></script>

<!--Put this code in the main document (splashscreen)-->

<html>
<head>
</head>

<body>

<!--This is where your main page would be and below are the links-->

<h1>
  <a href="frameset.htm?page1&page2&page3">test 1</a>
  <br>
  <a href="frameset.htm?page4&page5&page6">test 2</a>
  <br>
  <a href="frameset.htm?page7&page8&page9">test 3</a>
  <br>
</h1>

</body>
</html>

Submitted by John Denney

©2018 Martin Webb