On a webpage there's
<script>
function fn982734()
{
// some code
}
</script>
In my Greasemonkey script, I have the following code:
var fn = fields[5].getElementsByTagName("a")[0].getAttribute('onclick').substr(7,11);
console.log(fn); // outputs fn982734 to the firebug console
window[fn]();
This code does not work, and spawns an error in the error console: window[fn] is not a function. However, typing directly into firebug:
var fn = 'fn982734';
window[fn]();
works perfectly. What's going on?