我正在将 reCAPTCHA 集成到我的 Cappuccino 应用程序中,除了 reCAPTCHA 输入文本字段中的这个奇怪的输入功能之外,我还可以正常工作:似乎只有一些键有效,“qwrszcv”和其他一些字母可以正常工作,但大多数其他键不工作。
我借用了一些 mapkit 代码将 reCAPTCHA 脚本文件注入到头部,然后我将 reCAPTCHA div 注入到我制作的自定义 CPView 类中。
这是我的构造函数代码:
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self != nil)
{
var DOMScriptElement = document.createElement("script");
DOMScriptElement.src = "http://www.google.com/recaptcha/api/js/recaptcha_ajax.js";
DOMScriptElement.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(DOMScriptElement);
needsInitialization = YES;
console.log(self);
}
return self;
}
还有我的初始化代码:
- (id)initializeRecaptcha
{
if (needsInitialization)
{
DOMRecaptchaElement = document.createElement("div");
DOMRecaptchaElement.id = "recaptcha_div_id";
var style = DOMRecaptchaElement.style,
bounds = [self bounds],
width = CGRectGetWidth(bounds),
height = CGRectGetHeight(bounds);
style.overflow = "hidden";
style.position = "absolute";
style.visibility = "visible";
style.zIndex = 0;
style.left = "0px";
style.top = "0px";
style.width = width + "px";
style.height = height + "px";
_DOMElement.appendChild(DOMRecaptchaElement);
window.Recaptcha.create("my-recaptcha-key",
"recaptcha_div_id",
{
theme: "clean",
callback: window.Recaptcha.focus_response_field
}
);
needsInitialization = NO;
}
else
{
window.Recaptcha.reload();
}
}
我认为这与卡布奇诺传播事件的方式有关,但在我的一生中,我想不出一种方法来让这种输入发挥作用。