日期:2014-05-16  浏览次数:20292 次

为什么greasemonkey脚本无效?
为什么greasemonkey脚本无效?
点击按钮用firebug查看错误信息提示:
get_toodledo_list is not defined

JScript code

var get_toodledo_list = function(){
    alert(1);
}

var my_div=document.createElement("div");
my_div.innerHTML=    '<button onclick="get_toodledo_list();" style="position:fixed;right:0;bottom:0;">list</button>';
document.getElementsByTagName('body')[0].appendChild(my_div);





------解决方案--------------------
刚好写脚本也遇到这个问题。查看了一下wiki发现了问题所在。
http://wiki.greasespot.net/XPCNativeWrapper

Expando Properties do not work on XPCNativeWrappers. 
刚好onclick就是一个Expando Properties。

按照它示例的正确代码,稍作修改就行。