SharePoint Explored

Just another WordPress.com weblog

We can attach dynamically events with parameters in JavaScript

There are two basic accepted way to fire a function using a dynamic event handler:

Method 1

obj.onclick = handler_function;

  • No parameters are allowed in this method
  • Previous assignment of the event will be overwritten.

 

Method 2

obj.onclick= function()

{
handler_function(param1,param2);

other statements here

}

  • Used for multiple function firing or for firing a function with one or more parameters
  • Previous assignment for the event will be overwritten

 

Method 3

obj.attachEvent(“onclick”, function1)

  • Simple way to register multiple event handlers for the same event on one element.
  • Does not overwrite the previous assignments

The newly attached functions will be called in the sequence their of attachment

Advertisements

March 30, 2010 - Posted by | SharePoint Hack

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: