javascript - Setting event handlers to DOM objects -


i looking proper way attach dom events avoiding browser compatibility issues , found mozilla developers site states:

the old way assign this:

document.getelementbyid('cupcakebutton').onclick = getacupcake; 

as above, event object either global or argument. method may have problems , not preferred method, still works , lot of people still use it.

what type of problems refer to?

the obvious 1 mentioned, it replace assigned handler.

document.getelementbyid('id') should work in browsers except in old ones (netscape 4-, ie 4-), there should use document.layers['id'] , document.all[id] respectively.

ie 5 ie 7 have 1 more issue, return elements name='id' instead of elements id='id'. stuff up.

have @ jquery way attach dom event handlers avoiding browser compatibility issues.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -