onclick runs straight away....

W

windandwaves

Hi Gurus

I have the following JS:

var lin1 = document.getElementById('amui');
lin1.onclick = OWi(getimagename(mouseOvers[i1].src));

the onclick command executes straight away (before I click on the amui
element). What can I do about this? I dont understand it at all...

TIA

Nicolaas
 
W

windandwaves

Ian said:
windandwaves said:
Hi Gurus

I have the following JS:

var lin1 = document.getElementById('amui');
lin1.onclick = OWi(getimagename(mouseOvers[i1].src));

the onclick command executes straight away (before I click on the
amui element). What can I do about this? I dont understand it at
all...
You aren't assigning a function to onclick, you are calling the
function and assigning the result!

Assuming OWi the the function you wish to call,

lin1.onclick = function() { OWi(getimagename(mouseOvers[i1].src)); };

Great - thank you Ian. It starts to make sense.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top