Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Event handling in IE?

Reply
Thread Tools

Event handling in IE?

 
 
Brian Genisio
Guest
Posts: n/a
 
      04-28-2004
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').innerHTM L = 'blurred';">
</FORM>

<SCRIPT type="text/javascript">

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

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

</BODY>
</HTML>

 
Reply With Quote
 
 
 
 
Nick Howes
Guest
Posts: n/a
 
      04-29-2004
shouldn't

input1 = document.getElementById("myInput1");

be

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


"Brian Genisio" <(E-Mail Removed)> 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').innerHTM L = 'blurred';">
> </FORM>
>
> <SCRIPT type="text/javascript">
>
> input1 = document.getElementById("myInput1");
> input1.focus();
> input1.blur();
>
> alert(document.getElementById('mySPAN').innerHTML) ;
> </SCRIPT>
>
> </BODY>
> </HTML>
>



 
Reply With Quote
 
 
 
 
Brian Genisio
Guest
Posts: n/a
 
      04-29-2004
Nick Howes wrote:
> shouldn't
>
> input1 = document.getElementById("myInput1");
>
> be
>
> var input1 = document.getElementById("myInput1");
> ^^^
>
>
> "Brian Genisio" <(E-Mail Removed)> 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').innerHTM L = '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

 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      04-29-2004
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
signal handling and (structured) exception handling Peter C++ 34 10-17-2009 10:03 AM
python list handling and Lisp list handling Mark Tarver Python 22 04-26-2009 09:36 PM
Is faster handling hexadecimal values than handling chars? IƱaki Baz Castillo Ruby 1 04-15-2008 09:04 AM
ASP.NET Event handling. Makarand ASP .Net 0 07-24-2003 01:46 PM
Pager and Event Handling sunil ASP .Net 2 07-18-2003 09:08 PM



Advertisments