View Full Version : Does onClick exist in DOM

08-04-2002, 11:44 PM
I want to assign an onClick action to a button, that will alter the state of an onClick command on a banner advert further down the page.
Managed to change the href of the banner by naming it 'egglink', -
<a href="#" name="egglink">

and giving the button the DOM location -document.all.egglink.href="http://www.egg.com";

But cant figure out if its possible to change the onClick status of the banner using a similar DOM address.

.....am I being a bit vague??:confused:

08-05-2002, 09:29 AM
you mean like this?

document.all.egglink.onclick = function() {
// some stuff to do ;

08-05-2002, 08:11 PM
Yes, I thought this would do it, but it doesn't seem to eradicate the fault that I am experiencing.
I've attached a zip containing the test page I'm working on, basically, the button, displays or removes the banner at the bottom of the page. The status is stored in a cookie(adkil) for when the user returns.

However, if the page is loaded with the banners active, and the banner is then removed via the button, the 'removed' banner jumps the page forward when clicked, as the page space does not have the onClick value of return false;

If alternately the page loads with the banners disabled and then banners are reactivated via the button, clicking on the egg.com banner does nothing as the space is set to return false;

As you say, entering - document.all.egglink.onclick - into lines 31 and 32 should allow me to alter the state of onClick, just as I have altered the other page elements in those lines.

08-07-2002, 05:19 AM
it seems to be working for me in IE6. which browser are you using?

08-08-2002, 02:43 AM
I'm using IE5 - I cant make it run by changing the whole structure, deleting the whole setElements() function, and using 'location.reload();' but it doesnt look as fluid.:(

08-08-2002, 02:46 AM
Sorry - that should be I 'can' make it run!!!
(I just 'cant' type properly):)