dennise9@earthlink.net wrote:
> My exeternal JS works fine when the call is placed in the page head or
> body.
>
> But if I call the same javascript from a (clicked) text link on the
> page, the script throws a JS error when it executes.
>
> Help! I can't figure this out.
>
> The external JS file is "members.js". Here's the code:
>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> </head>
> <body bgcolor="#FFFFFF">
> <script Language="JavaScript"></script>
> <table width="90%" border="0" align="center">
> <tr>
> <td>
> <div align="center"><a href="home.htm"
> target="mainFrame">home</a></div>
> </td>
> <td>
> <div align="center"><a href="members.js"
> target="mainFrame">members</a></div>
> </td>
> <td>
> <div align="center"><a href="misc.htm"
> target="mainFrame">misc</a></div>
> </td>
> </tr>
> </table>
> </body>
> </html>
You load an external Javascript File like this. (best if you use it in
the <head> tag)
<script language="javascript" type="text/javascript"
src="javascriptfile.js"></script>
To then call a javascript function when you click a <a>-tag you can use
any of these (the second one might work the best for you)
1: <a onclick="function();">Some Name</a>
2: Some Name
3.1: <a id="someid">Some Name</a>
3.2: Code in javascript file:
var atag = document.getElementById("someid");
atag.onclick = function;
Received on Mon May 1 04:42:12 2006