Al's TAFE Certificate IV I.T. (Website Design) Exercises

JavaScript 2

A Bookmarking link for your site

First, this piece of code is placed in between the header tags like this;

<head>

<script type="text/javascript" src="scripts/bookmark.js"></script>

</head>

This is a copy of the safemail.js file refereed to above. The bold sections need to be changed with your information (IE: your website details & your message).

function bookmark()
{
if (document.all)
{
window.external.AddFavorite('http://www.webworkshop.net.au/~akendall/','Al`s TAFE Certificate IV I.T. (Website Design) Exercises');
}
else
{
alert('Netscape users please press ctrl-d to bookmark this page.\n\nThank you.');
}
}

Then the following piece of code is placed between the body tags like this;

<body>

<a href="javascript:bookmark()" title="If you find this site useful, please bookmark it!">Bookmark my site!</a>

</body>

This part is contained within the A tags as a hyperlink. You will need the edit the sections in bold like this;

<a href="javascript:bookmark()" title="If you find this site useful, please bookmark it!">Bookmark my site!</a>

The first bold section is the title which will display when the user mouses over the link, the second bold section is the Link title you want seen on the page.

Here's a sample; Bookmark my site!

A safe email script

First, this piece of code is placed in between the header tags like this;

<head>

<script type="text/javascript" src="scripts/safemail.js"></script>

</head>

This is a copy of the safemail.js file refereed to above. This .js file should NOT be changed.

function safe mail(name, domain, display) {
displayed=(typeof(display)=="undefined") ? name+"@"+domain : display
document.write('<a href=mailto:' + name + '@' + domain + ' class="dblue">' + displayed + '</a>');
}

Then the following piece of code is placed between the body tags like this;

<body>

<script>safe mail('atkendall','gmail.com','Contact Al')</script>

</body>

At each insertion you need to edit the e-mail address (highlighted in bold) like this;

<script>safe mail('atkendall','gmail.com','Contact Al')</script>

The first bold section is the first part of the e-mail (before the @ symbol), the second bold section is the URL of the e-mail & and the third bold section is the Link title you want seen on the page.

Here's a working sample.