When I write a GreaseMonkey script, if I create a div and set onclick to alert it works:
var btn = document.createElement('div');
btn.setAttribute('onclick',"alert('clicked!');");
However, if I ask it to do something else that was defined earlier then it fails:
function graphIt() {...};
var btn = document.createElement('div');
btn.setAttribute('onclick',"graphIt();");
Is there any way I can bind a function to the onclick event of a div?