I got a link in my html code with an onclick event handler.
The handler insert a link somewhere in my code with himself an onclick event handler.
here is a fiddle representing this:
My problem is that the onclick handler on the DOM generated link is automatically called.
What did I did wrong?
eLink.onclickshould have a closure assigned to it, not a string.If you want to go with the string version, use
eLink.setAttribute("onclick","......");, however this is not recommended.Alternatively, just do this:
However, might I ask why you can’t just set the appropriate
hrefand addtarget="Images"?