// Function - List Anchors
// Description - opens new page with a list of all the links on a links page
function listanchors(){
// Create the HTML for the Page Header - using the title of the current page
var myheader = "<head><title>Links In "+document.title+"</title></head>";
// Add <body> tag to header
myheader = myheader + "<body>";
// Create <font> tag
var myfont = "<font style=\"font: 8pt Verdana, Arial, Helvetica,
Sans-serif;line-height:18pt;\" face=\"verdana, tahoma, geneva\" size=\"-1\" >";
// Add page header text
var mytext = "<center><b>Links in " + document.title + "</b><ol></center>";
// Add </font> tag
var myendfont = "</font>";
// Add </body> tag
var myendheader = "</body>";
// First, determine what browser we're using
// Assume Navigator, but check for IE
listanchors.nav=true;
if (navigator.appName.indexOf("Microsoft") != -1) listanchors.nav = false;
// Open a new window, with name "navwin", status bar, menu bar, scroll bars,
// allow resizing and 600 * 300
var newwin=window.open("","navwin","status=yes,menubar=yes,scrollbars=yes,
resizable=yes,width=600,height=300");
// Write initial html
newwin.document.write(myheader + myfont + mytext);
// List all anchors - document.links is an array of all
// the hypertext links in the document
for(var i=0;i<document.links.length;i++)
{
// For each anchor object, determine the text to display.
// First, try to get the text between the <A> and </A> using a
// browser dependent property. If none, use the name instead.
if ((listanchors.nav==false) && (document.links[i].name!='')) {
// Internet Explorer - create List Item HTML
newwin.document.write('<LI><A HREF="' + document.links[i] + '\">');
newwin.document.write(document.links[i].name);
newwin.document.writeln('</A><BR>');
}
else if (listanchors.nav==true) {
// Netscape navigator - create List Item HTML
newwin.document.write('<LI><A HREF="' + document.links[i] + '\">');
newwin.document.write(document.anchors[i].name);
newwin.document.writeln('</A><BR>');
}
}
// Add close text to close the window when clicked
newwin.document.write("</ol><center><a href='javascript:window.close()'
>close</a></center><br>");
// Write </body> to close document
newwin.document.write(myendfont + myendheader);
newwin.document.close();
}
|