While working for my project , I found a strange problem with the setAttribute() method.
//Trying to set the onclick event for the element.
document.getElementById("cvId").setAttribute('onclick','return false;');
This works fine in Firefox , But fails in IE. To make it work in IE I did the respective changes.
document.getElementById("cvId").onclick=function(){return false;};
//Or you can directly call a javascript function.
document.getElementById("cvId").onclick=function(){DoSomething();};
//Declaraion of function..
function DoSomething()
{
return false;
}
This change works fine in IE and Firefox.Hope this is helpful.
*Please dont forget to leave a comment before leaving.
No comments:
Post a Comment