繁体   English   中英

IE8中的jQuery错误

[英]Error with jquery in ie8

我收到此错误:

网页错误详细信息

用户代理:Mozilla / 4.0(兼容; MSIE 8.0; Windows NT 5.1; Trident / 4.0; .NET4.0C; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)时间戳:周二, UTC 2012年6月26日11:31:22

消息:对象不支持此属性或方法行:56字符:650代码:0

URI: http://api.apps.com/html/81

消息:对象不支持此属性或方法行:56字符:738代码:0

URI: http://api.apps.com/html/81

我不能依靠那个调试器,因为当我查看源代码时,我认为第56行是长行,而且我不知道错误的真正位置在哪里? 有没有办法跟踪错误? 该错误不支持什么?这是第56行:

function send_email(to) {
    if (to.length == 0) {
        $("#email_loader").html("<p>Please enter an `email address</p>");
        $("#email_response").fadeIn(250);
    }
    else {
        _gaq.push(['_trackEvent', 'Email', FA.appID]);
        $("#email_loader").html("<img src='http://apps.com/img/ajax_load.gif' />");
        $("#email_response").fadeIn(500);
        $.get("/inc_appdl_main_api.php", {
            to: to,
            app_id: FA.appID
        }, function (data) {
            if (data.length > 0) {
                $("#email_loader").html(data);
                $("#email_response").delay(1000).fadeOut(500);
            }
        });
        setTimeout(FA.iframeClose, 2000);
    }
};
function iframeClose() {
    parent.postMessage("closeFA", "*");
};
$("#to").keypress(function (event) {
    if ((event.which == '13') && ($(this).val().length > 0)) {
        to = $(this).val();
        event.preventDefault();
        send_email(to);
    }
});
$("#email").click(function () {
    to = $("#to").val();
    send_email(to);
});
function set_url_target(url) {

}

有没有一种方法可以在ie8中进行调试?

我看着记事本++。 它指向那里:char 791 to = $(“#to”)。attr('value'); send_email(to);

它出什么问题了

确保在加载页面时控制台/开发人员工具已打开,否则在尝试使用console.log时它将失败。

假设这不是问题,请尝试在各种函数调用周围自由添加console.log()语句,如下所示:

$("#email").click(function () {
    console.log('call 1...');
    to = $("#to").val();
    console.log('call 1 done.');
    send_email(to);
});

疯了,希望您会在控制台中看到类似

LOG: call 7...

没有匹配的LOG: call 7 done. 然后,您知道罪魁祸首是谁。

该错误提到了几个字符数字,这些字符使您接近两个.val()调用。 因此,首先关注那些。 只需将它们替换为常量即可。

这为我工作:

IE由于"to"变量而引发错误。 我改变了这个:

$("#email").click(function () {
    to = $("#to").val();
    send_email(to);
});

对此:

$("#email").click(function () {
   var to = $("#to").val();
    send_email(to);
});

IE浏览器停止抛出错误!

暂无
暂无

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

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