dcsimg
Dynamically setting events
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abdel_Olakara
Posted On:   Thursday, January 25, 2007 10:29 AM

Hi everybody, i have a javascript that render the XML response from a servlet. My trouble is i have to dynamically add onclick event to some of the elements that i render.. for example some XML elements are rendered as DIV that contain images. now when i write: component.className = "imgView"; component.onClick = functionName; My code applies the style sheet, but doesn't add the onClick or any other event property to div,img or any other HTML elements. How can i do this? add a event dynamically? Thanks in advance -- Abdel Olakara http://olakara.googlepages.com    More>>

Hi everybody, i have a javascript that render the XML response from a servlet. My trouble is i have to dynamically add onclick event to some of the elements that i render.. for example some XML elements are rendered as DIV that contain images. now when i write:

component.className = "imgView";

component.onClick = functionName;

My code applies the style sheet, but doesn't add the onClick or any other event property to div,img or any other HTML elements.

How can i do this? add a event dynamically?

Thanks in advance

-- Abdel Olakara

http://olakara.googlepages.com

   <<Less

Re: Dynamically setting events

Posted By:   suresh_kumar  
Posted On:   Friday, February 16, 2007 06:49 AM


Hi,

I think you can try this fn



object.attachEvent("onmousedown",functionname);

Re: Dynamically setting events

Posted By:   Axel_Richter  
Posted On:   Thursday, January 25, 2007 12:56 PM

Hi



because JavaScript-DOM-properties are case sensitive, you have to write:


component.onclick = functionName;

You may also look the documentation at http://developer.mozilla.org/en/docs/DOM:element.onclick for Geckos and http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onclick.asp for Microsoft.



Greetings



Axel
About | Sitemap | Contact