[thelist] simple Javascript help

Chris Marsh chris at webbtech.co.uk
Fri Nov 1 11:19:10 CST 2002

Dear all

I have a number of elements on a page, each with an id. I want certain
javascript functions to fire on certain events, but I don't want to
specify event handlers in any tags nested within (but not including) the
body. If I have a function Init() that fires on page load, is there some
way I can do the following (the code is incorrect and for illustrative
purposes only):

function Init() {
  var foo = document.getElementById("bar");
  foo.onClick = alert("Eureka!");

Many thanks in advance...


Chris Marsh

More information about the thelist mailing list