tdellaringa
04-25-2005, 09:20 PM
Hi there,
I'm adding a link inside a DIV dynamically on my page using the DOM. This link needs to have a function tied to the onclick event handler. If I remember correctly, you cannot do this using .setAttribute - is that correct? (IE doesn't see it)
I had thought then you added it using the property of the object:
myLink.onclick = functionName; ( with or without the brackets?)
But this doesn't seem to work. My problem is compounded by the fact that I want the link to return false: The link should be this:
<a href="" onclick="toggleHelp();return false">Page Help</a>
Do I have to write this as an anonymous(?) function like:
myLink.onclick = function { statements here }
I'm rusty on this stuff it has been awhile, I can't remember the correct way. I also don't see a way to add the return false, or maybe 'return toggleHelp()' then return false in the function...still how would I add the return?
Thanks
Tom
I'm adding a link inside a DIV dynamically on my page using the DOM. This link needs to have a function tied to the onclick event handler. If I remember correctly, you cannot do this using .setAttribute - is that correct? (IE doesn't see it)
I had thought then you added it using the property of the object:
myLink.onclick = functionName; ( with or without the brackets?)
But this doesn't seem to work. My problem is compounded by the fact that I want the link to return false: The link should be this:
<a href="" onclick="toggleHelp();return false">Page Help</a>
Do I have to write this as an anonymous(?) function like:
myLink.onclick = function { statements here }
I'm rusty on this stuff it has been awhile, I can't remember the correct way. I also don't see a way to add the return false, or maybe 'return toggleHelp()' then return false in the function...still how would I add the return?
Thanks
Tom