Event handling in IE?

Discussion in 'Javascript' started by Brian Genisio, Apr 28, 2004.

  1. Ok, I am confused. The following code works in Mozilla 1.5, but it
    doesnt work in IE 6.

    The wierd thing about the IE failure, is that the text is changed in the
    onBlur event, but when I run alert, it is not changed yet.

    Anyone know why this is? I am a bit baffled.

    Brian

    <HTML>
    <HEAD>
    <TITLE>Blur Test</TITLE>
    </HEAD>


    <BODY>
    <SPAN id=mySPAN>BeforeCallback</SPAN>

    <FORM name=myForm>
    <INPUT id=myInput1 name=myInput1 type=text
    onBlur="document.getElementById('mySPAN').innerHTML = 'blurred';">
    </FORM>

    <SCRIPT type="text/javascript">

    input1 = document.getElementById("myInput1");
    input1.focus();
    input1.blur();

    alert(document.getElementById('mySPAN').innerHTML);
    </SCRIPT>

    </BODY>
    </HTML>
    Brian Genisio, Apr 28, 2004
    #1
    1. Advertising

  2. Brian Genisio

    Nick Howes Guest

    shouldn't

    input1 = document.getElementById("myInput1");

    be

    var input1 = document.getElementById("myInput1");
    ^^^


    "Brian Genisio" <> wrote in message
    news:408fa88d$1@10.10.0.241...
    > Ok, I am confused. The following code works in Mozilla 1.5, but it
    > doesnt work in IE 6.
    >
    > The wierd thing about the IE failure, is that the text is changed in the
    > onBlur event, but when I run alert, it is not changed yet.
    >
    > Anyone know why this is? I am a bit baffled.
    >
    > Brian
    >
    > <HTML>
    > <HEAD>
    > <TITLE>Blur Test</TITLE>
    > </HEAD>
    >
    >
    > <BODY>
    > <SPAN id=mySPAN>BeforeCallback</SPAN>
    >
    > <FORM name=myForm>
    > <INPUT id=myInput1 name=myInput1 type=text
    > onBlur="document.getElementById('mySPAN').innerHTML = 'blurred';">
    > </FORM>
    >
    > <SCRIPT type="text/javascript">
    >
    > input1 = document.getElementById("myInput1");
    > input1.focus();
    > input1.blur();
    >
    > alert(document.getElementById('mySPAN').innerHTML);
    > </SCRIPT>
    >
    > </BODY>
    > </HTML>
    >
    Nick Howes, Apr 29, 2004
    #2
    1. Advertising

  3. Nick Howes wrote:
    > shouldn't
    >
    > input1 = document.getElementById("myInput1");
    >
    > be
    >
    > var input1 = document.getElementById("myInput1");
    > ^^^
    >
    >
    > "Brian Genisio" <> wrote in message
    > news:408fa88d$1@10.10.0.241...
    >
    >>Ok, I am confused. The following code works in Mozilla 1.5, but it
    >>doesnt work in IE 6.
    >>
    >>The wierd thing about the IE failure, is that the text is changed in the
    >>onBlur event, but when I run alert, it is not changed yet.
    >>
    >>Anyone know why this is? I am a bit baffled.
    >>
    >>Brian
    >>
    >><HTML>
    >> <HEAD>
    >> <TITLE>Blur Test</TITLE>
    >> </HEAD>
    >>
    >>
    >> <BODY>
    >> <SPAN id=mySPAN>BeforeCallback</SPAN>
    >>
    >> <FORM name=myForm>
    >> <INPUT id=myInput1 name=myInput1 type=text
    >> onBlur="document.getElementById('mySPAN').innerHTML = 'blurred';">
    >> </FORM>
    >>
    >> <SCRIPT type="text/javascript">
    >>
    >> input1 = document.getElementById("myInput1");
    >> input1.focus();
    >> input1.blur();
    >>
    >> alert(document.getElementById('mySPAN').innerHTML);
    >> </SCRIPT>
    >>
    >> </BODY>
    >></HTML>
    >>

    >
    >


    Sure... I suppose (do not top post on this group please). Using var
    doesnt really matter for this example. This is just a paird down
    version of what I really have, to show the problem... and your comment
    does nothing to make progress towards solving the problem... purely
    symantecs... optional symantecs in this case.

    Anyways, another curious thing is that if I call the exact same alert
    call immediately after the first one, the second one reports correctly,
    and the first one is still broken.

    Sigh. I really cannot understand what is going on here. I have a
    pretty good grasp of the inner-workings of Javascript, butI am not sure
    why IE does this.

    Brian
    Brian Genisio, Apr 29, 2004
    #3
  4. Brian Genisio

    Mike Guest

    replace

    > alert(document.getElementById('mySPAN').innerHTML);


    with

    setTimeout(test,100)
    function test(){
    alert(document.getElementById('mySPAN').innerHTML);
    }


    This worked in IE 6.0. I've experienced weird redering issues with IE
    during the initial parsing. In this case IE 6.0 diplayed the "blurred"
    mesage correctly but the alert was wrong. Like it executed the script before
    it resets the innerHTML value. Perhaps the scripted events are not executed
    until after the document status is complete. Dunno.

    Sorry no real answer just a work around.
    Mike, Apr 29, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sunil

    Pager and Event Handling

    sunil, Jul 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    375
    sunil
    Jul 18, 2003
  2. Makarand

    ASP.NET Event handling.

    Makarand, Jul 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    403
    Makarand
    Jul 24, 2003
  3. Mark Tarver
    Replies:
    22
    Views:
    1,274
    J Kenneth King
    Apr 26, 2009
  4. Peter
    Replies:
    34
    Views:
    1,911
    James Kanze
    Oct 17, 2009
  5. Iñaki Baz Castillo
    Replies:
    1
    Views:
    174
    Iñaki Baz Castillo
    Apr 15, 2008
Loading...

Share This Page