简体   繁体   中英

Error with jquery in ie8

I get this error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; 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) Timestamp: Tue, 26 Jun 2012 11:31:22 UTC

Message: Object doesn't support this property or method Line: 56 Char: 650 Code: 0

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

Message: Object doesn't support this property or method Line: 56 Char: 738 Code: 0

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

I cant rely on that ie debugger , cause when i view source, i see line 56 as a long line, and i dont know where the error really is? is there a way to trace the error? what does the error doesnt support.Here is line 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) {

}

is there a way to debug in ie8?

I looked in notepad++. it points to there: char 791 to=$("#to").attr('value');send_email(to);

whats wrong with it

Make sure the console/developer tools is open when you load the page, or else it will fail when you try to use console.log .

Assuming that's not the problem, try liberally adding console.log() statements around the various function calls, like so:

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

Go crazy with it, and hopefully you'll see something in the console like

LOG: call 7...

with no matching LOG: call 7 done. . Then you know who the culprit is.

The error mentions a couple character numbers, and those land you close to two of the .val() calls. So focus on those first. Just replace them with a constant.

This worked for me:

IE threw an error because of the "to" variable. I changed this:

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

To this:

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

IE stopped throwing the error!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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