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

Related items

Automatic Redirection

Automated Links

Array-Tours- source1

You are here: irt.org | Articles | JavaScript | Location | Array-Tours [ previous next ]

Published on: Wednesday 1st January 1997 By: Martin Webb

tour.htm source code

<html>

<head>
<title>Tour Navigation Frame</title>
</head>

<script language="JavaScript"><!--

//This script defines an object called 'Link'
function Link(href,text) {
  this.href = href;
  this.text = text;
}

//This script creates an array called 'myLink'
var item = 0;
var myLink = new Array();

//This script creates a new instance of a 'Link' object
function setLink(href,text) {
  myLink[item] = new Link(href,text);
  item++;
}

//This script populates the array 'myLink' with 'Link' objects
setLink('tour1.htm','Array Tour Start');
setLink('tour2.htm','Tour Components');
setLink('tour3.htm','Frames');
setLink('tour4.htm','Arrays of Objects');
setLink('tour5.htm','Forms, Selections and Options');
setLink('tour6.htm','Navigation');
setLink('tour7.htm','Automating Headers and Footers');
setLink('tour8.htm','Source Code');

//The following parameter 'n' controls the position within the tour

var n=0;

//The following scripts are used by the form 'form1' within the frame 'nav'

function goFirst() {
  if (n != 0) {
    n = 0;
    self.workarea.location.href =
      myLink[n].href;
  }
}

function goBack() {
  if (n != 0) {
    n--;
    self.workarea.location.href =
      myLink[n].href;
  }
}

function goHome() {
  location.href = 'index.htm';
}

function goForward() {
  if (n != (item - 1)) {
    n++;
    self.workarea.location.href =
      myLink[n].href;
  }
}

function goLast() {
  if (n != item -1) {
    n = item - 1;
    self.workarea.location.href =
      myLink[n].href;
  }
}

// This script navigates to the location of an option
// without the need of a cgi script:
function openDoc (object) {
  var string = object.options[object.selectedIndex].value;
  if (string != '' && n != object.selectedIndex) {
    n = object.selectedIndex;
    self.workarea.location.href = string;
  }
  return false;
}

// The following scripts output formatted text, as used
// within the child frames

function header() {
  return '<h1>' + myLink[n].text + '<\/h1>';
}

function footer() {
  return '<hr><center>Page ' +
     (n + 1) + ' of ' + item +
    '<\/CENTER><BR>';
}
//--></script>

<frameset
  frameborder="0"
  framespacing="0"
  rows="50,*">
<frame 
  scrolling="no"
  frameborder="0"
  marginheight="0"
  marginwidth="0"
  name="nav"
  noresize
  src="tour-n.htm">
<frame
  scrolling="yes"
  frameborder="0"
  marginheight="0"
  marginwidth="10"
  name="workarea"
  noresize
  src="tour1.htm">
</frameset>

</html>

Related items

Automatic Redirection

Automated Links

©2018 Martin Webb