setattribute in javascript
<p>This is my code to dynamically set the onclick attribute to links .But without me clicking the links itself the alert is triggerd.Pls help</p>

<pre><code>window.onload = function()
{
var links = document.getElementsByTagName("a") ;
        for(var i=0;i&lt;links.length;i++)
        {
            elm = links[i];
            elm.setAttribute("onclick", alert("you clicked a lik"));
        }
}
</code></pre>
