English 中文(简体)
jquery change() on input box in IE6 - can t remove focus
原标题:

I have a checkout page that unobtrusively checks to see whether a customer has ordered from us before.

After they fill in their e-mail address and focus to the next box, I look up the e-mail and present a welcome back type thing with option to remember their details.

I m getting a problem in IE6 - whenever the focus is lost from the input box, the ajax function runs as normal but focus is returned back to the input box. This means that whenever the customer tries to click away from the e-mail input box, they keep getting returned to it and cannot proceed.

Is there a way of stopping this behaviour?

  // check when the e-mail box is changed
  $("#email").change(function(event) {
    $.ajax({
        type: "POST",
        url: "procBasketEmailLookup.php", 
        data: $("#checkoutform").serialize(),
        success: function(response) {
            $( #emailstuffOutput ).hide();
            $( #emailstuffOutput ).html(response);
            $( #emailstuffOutput ).show( slow );
        }
        });
        // DON T ALLOW THE PAGE TO SUBMIT
    return false;
    });
问题回答

Try:

jQuery("#emailInputField").blur();

Put that in the success handler of your AJAX call, or even in your change() handler. I can t tell from your question if it s the AJAX call that s causing the problem, or if it s the change() handler. But this should work.

EDIT

With regard to Pointy s comment. Using blur() messes up the tab sequence. Also, Pointy and Mattias pointed out that you re returning false from your handler. There s no need for you to do that since you re not in a submit() handler. The return false; might also be the cause of your problem.





相关问题
Image rendered with wrong colors in IE8

I have a gradient image as a PNG (no transparency) in a web-page. By taking a screenshot of Chrome showing the page and cropping the image from the page, I see the exact same colors are drawn as the ...

Determine Mobile Internet Explorer version

I need to determine the version of Mobile Internet Explorer on a Windows Mobile 6.1 device. So that I can report the same user-agent string as is being used by Mobile Internet Explorer. The user-...

CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

Internet Explorer only part loading JavaScript/CSS

I m having trouble with my local development environment where IE (6 through to 8) is only part loading JavaScript/CSS files. It throws random errors at random places in jquery.min.js every time I ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...

热门标签