Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Frame | Q1499 [ previous next ]

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

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


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.