Tuesday, June 9, 2009

Resolved IE specific issue related to calling function at onclick event using createElement



I have explained about inconsistent behavior of createElement function in IE and mentioned workaround also in my previous post.

Today, we faced similar issue with createElement. This issue is also again related to IE.

Find below the sample code which will create a new button. A function "showmsg" should be called on clicking the new button.


newbutton=document.createElement("Input");
newbutton.name="btnmsg";
newbutton.type="button";
newbutton.setAttribute("onClick","showmsg(this);");


The above code worked fine in FireFox. But it didn't work in IE.

Once after searching the internet we found below workaround for resolving this issue.

Instead of using setAttribute for onclick event, we used below code.

newbutton.onclick=function(){showmsg(this);}

Once after making the above change the code is working fine in both IE and FireFox.

More Articles...

0 comments:

Popular Posts - This week

        

Classified Links

  • Contact Us to show your links/advertisements in our wesbsites/blogs

Popular Posts - All Time

For Any of your sofware development needs contact us at qualitypointmail@gmail.com or rajamanickam.a@gmail.com
QualityPoint

Translate

   
Thanks for visiting our blog