Looking at that code, two things jumped out at me, but it wasn't
either of them. :-)

The third thing was more subtle:  This line is missing from

    $('area').stopObserving('mouseover', showLink);

Consequently, as the mouse is moved over the div, showLink is fired
repeatedly.  I don't know why, but that seems to muck things up in
IE.  Adding the line above fixed it; and it also makes sense as you
don't want to constantly repeat the logic in showLink.

FWIW, one of the things I noticed that _wasn't_ the problem probably
still needs fixing:  You're inserting the toInsert span into the div
without removing it from its original location.  I don't think that's
ideal.  Here's how I would modify showLink:

* * * *
function showLink() {
    var toInsert;
    var area;

    area = $('area');
    area.stopObserving('mouseover', showLink);

    toInsert = $('toInsert');
* * * *

The changes are:

1. stopObserving area so showLink doesn't get repeated calls
2. Cache element references to a local variables rather than looking
them up repeatedly
3. Remove toInsert from its old location before inserting it elsewhere
4. Show it only once it's in its new location

(The other of the two things I originally noticed was just me being
pessimistic about IE and didn't turn out to be anything, so don't
worry about it.)

Hope this helps,
T.J. Crowder
tj / crowder software / com

On Mar 28, 10:00 pm, Greg <[EMAIL PROTECTED]> wrote:
> Hello Folks,
> I've got a problem on a type of event in IE.
> It works perfectly on Firefox 2, Konqueror 3.5.8 but not on IE 6.
> Here is a very simple test case 
> :http://paul.gregory.free.fr/prototype-IE-problem/bug.html
> (I've also posted the source code on the bottom of this message)
> In a nutshell, a link is shown on mouse over on a div.
> The problem is that the event on the link is never sent on IE.
> Grégory
> =========================================
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
> TR/xhtml11/DTD/xhtml11.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en">
> <head>
>         <script type="text/javascript" src="prototype.js"></script><!--
> Prototype's version -->
>         <script type="text/javascript">
>                 // On load, initialize events
>                 Event.observe(window, 'load', initializeEvents);
>                 function initializeEvents(e) {
>                         $('area').observe('mouseover', showLink);
>                         $('eventToLaunch').observe('click', function(e) { 
> alert("Ok, it
> works !"); Event.stop(e); });
>                 }
>                 function showLink() {
>                         $('toInsert').show();
>                         $('area').insert( $('toInsert') );
>                 }
>         </script>
> </head>
> <body>
>         <div id="area" style="width: 400px; height: 400px; border: 1px solid
> red">
>                 A link will appear on mouse over.
>         </div>
>         <span id="toInsert" style="display: none;">
>                 <a href="" id="eventToLaunch">links on wich event is 
> registered for
> Firefox 2, Konqueror but not IE 6 ! Why ?</a>
>         </span>
> </body>
> </html>
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to