$(Constants.Selectors.Submit_Button).bind('click', function () {
GM_log('Event run: id = ' + this.id + ' self = ' + this);
});
The above code appears to run when the click event is triggered by the document (or otherwise some other all-page encompassing element or set of elements.) The console output is this: Script: Event run: id = undefined self = [object XPCNativeWrapper [object HTMLDocument]]
上述代码似乎在文档触发click事件时运行(或者其他一些包含所有页面的元素或元素集。)控制台输出如下:脚本:事件运行:id = undefined self = [object XPCNativeWrapper [对象HTMLDocument]]
The selector is a simple string "#buttonID" where buttonID is significantly obfuscated (I'm sure there are no name conflicts) and is part of an HTML form I have injected into the page. (Namely an input element with the attribute "type" set to "button").
选择器是一个简单的字符串“#buttonID”,其中buttonID被显着混淆(我确定没有名称冲突),并且是我注入页面的HTML表单的一部分。 (即,属性“type”设置为“button”的输入元素)。
Does anyone know why this might be? I'm clueless on this one.
有谁知道为什么会这样?我对这一点毫无头绪。
2 个解决方案
#1
0
What kind of version of jQuery you are using? It's been a while since i played in GM, but i found code of mine and it was done with 1.3.2 and it's still working for me as long as click function is under document ready function.
你正在使用什么样的jQuery版本?自从我在通用汽车公司工作以来已经有一段时间了,但是我发现了我的代码并且它已经完成了1.3.2并且只要点击功能处于文档就绪功能下它仍然适用于我。
var $jq = jQuery.noConflict();
$jq(function(){
$jq('#buttonID').click(function(){
runCode;
});
});
#2
0
instead of doing something like this:
而不是做这样的事情:
var elmLink = document.getElementById('somelink');
elmLink.onclick = 'my_func(this)';
do something like this:
做这样的事情:
var elmLink = document.getElementById('somelink');
elmLink.addEventListener("click", my_func, true);
from here
从这里
#1
0
What kind of version of jQuery you are using? It's been a while since i played in GM, but i found code of mine and it was done with 1.3.2 and it's still working for me as long as click function is under document ready function.
你正在使用什么样的jQuery版本?自从我在通用汽车公司工作以来已经有一段时间了,但是我发现了我的代码并且它已经完成了1.3.2并且只要点击功能处于文档就绪功能下它仍然适用于我。
var $jq = jQuery.noConflict();
$jq(function(){
$jq('#buttonID').click(function(){
runCode;
});
});
#2
0
instead of doing something like this:
而不是做这样的事情:
var elmLink = document.getElementById('somelink');
elmLink.onclick = 'my_func(this)';
do something like this:
做这样的事情:
var elmLink = document.getElementById('somelink');
elmLink.addEventListener("click", my_func, true);
from here
从这里