简体   繁体   English

文本字段(针对特定网站)没有onClick()事件

[英]No onClick() event for text-field (for specific sites)

Background 背景

I'm working on a custom browser implementation based on Qt 4.8 (QtWebkit 2.0). 我正在研究基于Qt 4.8(QtWebkit 2.0)的自定义浏览器实现。 I'm trying to pop-up a virtual keyboard whenever the user clicks on a text field 每当用户单击文本字段时,我都试图弹出虚拟键盘

  • I have some simple JavaScript which adds a listener for a click event on any text field 我有一些简单的JavaScript,可在任何文本字段上为click事件添加侦听器
  • When a click is detected, it invokes a slot through the myWebObj object as shown below. 当检测到单击时,它将通过myWebObj对象调用一个插槽,如下所示。

     $("input[type=text]").click(function() { var name = $(this).attr('id'); alert("Text field " + 'id' + " clicked"); }); 

Problem 问题

The code above works fine for most websites. 上面的代码对大多数网站都适用。 For example it works for How to Enter a Blocked Website and detects all the text fields. 例如,它适用于“ 如何输入被阻止的网站”并检测所有文本字段。

However, for www.google.com, a click on the search bar doesn't invoke the click function. 但是,对于www.google.com,在搜索栏上单击不会调用单击功能。

Meanwhile on any standard browser like Firefox or Chrome the javascript given above works perfectly. 同时,在任何标准浏览器(如Firefox或Chrome)上,上面给出的javascript均可完美运行。

Any help is appreciated. 任何帮助表示赞赏。

i had no problem in google.com but for apple you wont get it because their script is not your normal jquery. 我在google.com上没有问题,但是对于苹果,您不会得到它,因为他们的脚本不是您的普通jquery。 here is their $('selector') code 这是他们的$('selector')代码

function $(element) {
    if (arguments.length > 1) {
        for (var i = 0, elements = [], length = arguments.length; i < length; i++)
            elements.push($(arguments[i]));
    return elements;
    }
    if (Object.isString(element))
        element = document.getElementById(element);
        return Element.extend(element);
}

you can check well what it does, but for your case i think your $("input[type=text]").click or $("input[type=text]").on('click', function should be completely ok. 您可以很好地检查它的功能,但是对于您的情况,我认为您的$(“ input [type = text]”)。click或$(“ input [type = text]”)。on('click',function应该是完全可以。

For the virtual keyboard, you can try this: https://github.com/Mottie/Keyboard/wiki 对于虚拟键盘,您可以尝试以下操作: https : //github.com/Mottie/Keyboard/wiki

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM