Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15181

Re: Button mouseover is spotty

Date 2012-07-24 16:03 -0500
Subject Re: Button mouseover is spotty
From Bint <bint@ign.com>
Newsgroups comp.lang.javascript
Message-ID <CC3477D2.C394%bint@ign.com> (permalink)
References <CC34639E.C261%bint@ign.com> <XnsA09AE8A77C6BBeejj99@194.109.133.133>

Show all headers | View raw


Sorry,  I am a moron.  But I did figure out the problem -- another div
(transparent) was blocking the parts of the div.

I have another question though.  I am creating another element, a span, like
this:

                    var linktext = document.createElement( 'div' );
                    linktext.style.position = 'absolute';
                    linktext.style.top = '50px';
                    linktext.style.width = '100%';
                    linktext.style.textAlign = 'center';
                   
                    linktext.innerHTML = '<span
id="linktext"">'+thisURL+'</span>';
               
                    container.appendChild( linktext );


The box shows up but when I click on it, the mouse events seem to go right
through it.  I would like to be able to select and copy the text with the
mouse.  What do I need to do for that?

I thought that I needed to stop the mouse events from bubbling up to the
parent, so I changed it to this:

            function cancelBubble(e) {
                console.log("cancel Bubble!");
                var evt = e ? e:window.event;
                if (evt.stopPropagation)    evt.stopPropagation();
                if (evt.cancelBubble!=null) evt.cancelBubble = true;
            }
            
            
                    var linktext = document.createElement( 'div' );
                    linktext.style.position = 'absolute';
                    linktext.style.top = '50px';
                    linktext.style.width = '100%';
                    linktext.style.textAlign = 'center';
                   
                    linktext.innerHTML = '<span
id="linktext"">'+thisURL+'</span>';
               
                    linktext.addEventListener("click", cancelBubble,false);
                    linktext.addEventListener("touchstart", cancelBubble,
true);
                    linktext.addEventListener("touchmove", cancelBubble,
true);
                    linktext.addEventListener("touchend", cancelBubble,
true);
                    linktext.addEventListener("touchcancel", cancelBubble,
true);
                    linktext.addEventListener("mousemove", cancelBubble,
true);

                    container.appendChild( linktext );
                }
                

This does stop the event from bubbling back, but it does not let me select
the text.  

Thanks
B






Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Button mouseover is spotty Bint <bint@ign.com> - 2012-07-24 14:37 -0500
  Re: Button mouseover is spotty "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-07-24 20:52 +0000
    Re: Button mouseover is spotty Bint <bint@ign.com> - 2012-07-24 15:56 -0500
    Re: Button mouseover is spotty Bint <bint@ign.com> - 2012-07-24 16:03 -0500
      Re: Button mouseover is spotty RobG <rgqld@iinet.net.au> - 2012-07-31 19:33 -0700

csiph-web