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

Related items

Writing a midi hifi system in JavaScript

JavaScript Beginners Start Here

Keeping Count of Downloads

JavaScript Games

Online JavaScript Resources

Automating the Previous and Next buttons

Reading the contents of a directory

Automating NEW!

Arguments Array

Odds and Sods

You are here: irt.org | Articles | JavaScript | Miscellaneous | Odds and Sods [ previous next ]

Published on: Wednesday 5th March 1997 By: Martin Webb

Frames

To remove frames:

<a href="http://www.yahoo.com" target="_top">Remove Frames</a>

To check if the current document is loaded in a frame:

<body onLoad="if (parent.location.href != self.location.href)
    {... do something ...}; return true;">

To change the contents of two or more frames:

<a href="JavaScript:jump()">Change Frames</a>

<script language="JavaScript"><!--
function jump() {
  parent.frame1.location.href =
    'http://www.yahoo.com';
  parent.frame2.location.href =
    'http://www.altavista.digital.com/';
}
//--></script>

Mailto

The following mailto attributes do not currently work with Internet Explorer:

Dates

To reformat the last modified date:

<script language="JavaScript"><!--
function makeArray0() {
  for (i = 0; i<makeArray0.arguments.length; i++)
     this[i] = makeArray0.arguments[i];
}

var days = new makeArray0(
  'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  'Thursday', 'Friday', 'Saturday'
);

var months = new makeArray0(
  'January', 'February', 'March',
  'April', 'May', 'June',
   'July', 'August', 'September',
  'October', 'November', 'December'
);

function nths(day) { 
  if (day == 1 || day == 21 || day == 31)
    return 'st';
  else
   if (day == 2 || day == 22)
     return 'nd';
   if (day == 3 || day == 23)
     return 'rd';
   else return 'th';
}

function y2k(number) {
  return (number < 1000) ? number + 1900 : number;
}

var last = document.lastModified;
var date = new Date(last);
document.write(
  'Last updated on ' + days[date.getDay()] + ' ' +
  date.getDate() + nths(date.getDate()) + ' ' +
  months[date.getMonth()] + ', ' +
  (y2k(date.getYear())) + '.'
);
//--></script>

Which produces:

Refresh

To refresh the current page 10 seconds after it has loaded:

<body onLoad="window.setTimeout('RefreshScreen()',10000)">

<script language="JavaScript"><!--
function RefreshScreen()
{
     location.href = self.location.href;
}
//--></script>

Or:

<body onLoad="window.setTimeout('RefreshScreen()',10000)">

<script language="JavaScript"><!--
function RefreshScreen()
{
     history.go(0);
}
//--></script>

Alternatively use the following in the HEAD section:

<META HTTP-EQUIV="Refresh" CONTENT="10">

Related items

Writing a midi hifi system in JavaScript

JavaScript Beginners Start Here

Keeping Count of Downloads

JavaScript Games

Online JavaScript Resources

Automating the Previous and Next buttons

Reading the contents of a directory

Automating NEW!

Arguments Array

©2018 Martin Webb