Try this:-
Code:
<html>
<head>
</head>
<body onload = "listem()">
<script type = "text/javascript">
function listem(){
var myArray = new Array(); // text of the links
myArray[0] = "Bob's Website";
myArray[1] = "Jim's Website";
myArray[2] = "Jill's Website";
myArray[3] = "Google";
var links = new Array();
links[0] = "http://www.bobswebsite.com"; // corresponding urls
links[1] = "http://www.jimswebsite.com";
links[2] = "http://www.bobswebsite.com";
links[3] = "http://www.google.com";
for (var i=0; i <myArray.length; i++) {
document.write(myArray[i].link(links[i]));
document.write("<br>")
}
}
</script>
</body>
</html>
You should be aware that document.write() statements must (as here) be run before the page finishes loading. Any document.write() statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page (including the Javascript which called it). So document.write() is at best really only useful to write the original content of your page.
It cannot be used to update the content of your page after that page has loaded.
"I know that you believe that you understand what you think I said, but, I am not sure you realise that what you heard is not what I meant". (Robert
McCloskey)