Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 聚焦事件使用on not激发_Javascript_Jquery_Focusin - Fatal编程技术网

Javascript 聚焦事件使用on not激发

Javascript 聚焦事件使用on not激发,javascript,jquery,focusin,Javascript,Jquery,Focusin,我正在尝试对文本框的foucsin执行一些操作。但是,由于某些原因,事件从未触发 $(".ddlAddListinTo li").click(function () { var urlstring = "../ActionTypes"; $.post(urlstring, function (data) { $(window.open(urlstring, 'Contacts', 'width=750, height=400')).load(function (e

我正在尝试对文本框的
foucsin
执行一些操作。但是,由于某些原因,事件从未触发

$(".ddlAddListinTo li").click(function () {
    var urlstring = "../ActionTypes";
    $.post(urlstring, function (data) {
        $(window.open(urlstring, 'Contacts', 'width=750, height=400')).load(function (e) {

      //  Here "this" will be the pop up window. 
             $(this.document).find('#txtAutocompleteContact').on({
                   'focusin': function (event) {
                   alert('You are inside the Contact text box of the Contacts Popup');
                         }
                    });
               });
         });
});

这样做时,通常必须找到正文或使用
contents()
访问内容,如中所示

$(this.document).contents().find('#txtAutocompleteContact')
但在这种情况下,使用一点简单的javascript似乎更合适:

$(".ddlAddListinTo li").on('click', function () {
    var urlstring = "../ActionTypes";
    $.post(urlstring, function (data) {
        var wind = window.open(urlstring, 'Contacts', 'width=750, height=400');

        wind.onload = function() {
             var elem = this.document.getElementById('txtAutocompleteContact');

              $(elem).on('focus', function() {
                  alert('You are inside the Contact text box of the Contacts Popup');
              });
         }
    });
});

非常感谢。尝试了这两种方法,但都没有成功。然后你必须进行一些调试,将这个.document记录到控制台中,然后查看你得到了什么。我尝试将一个输入元素添加到弹出窗口的表单字段中,它确实起了作用。var$formCopy=''$(this.document).find(“#divfrmInfo”).html($formCopy);但是({})上的$(this.document.contents().find('#txtautompletecontact');它不起作用。