• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stop text select on click

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way to stop the browser from selecting text when a user clicks on it? I have a JavaScript that opens or closes a menu you when you click on a list item. Frequently, however, when a user clicks on the "button" the text is selected instead, so the on click event is not triggered.

Any way around this?

Using anchor elements isn't an option because the sucky CMS we have loses its data when you use empty anchors, including simply hash marks and javascript declarations.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The user must be doing a drag rather than a click to effect a selection. There's not much you can do about that.

Or is there more to the story?
 
Marc Luzietti
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's possible that minute mouse movements cause the problem, but I notice that if I double click on a word in a post, it is highlighted. Perhaps this is a windows problem. In testing just now, it occurs in all web enabled applications, but in a non-web enabled app it did not. I see it in both IE and FF, Dreamweaver, and Lotus Notes. I really only care about the browsers though. Also, if I triple click an entire line is selected.
[ March 05, 2007: Message edited by: Marc Luzietti ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's the way things work. I guess you could try capturing the clicks and double clicks and timing them to cancel the event bubbling. But that all sounds like a lot of effort to go through for something no one else seems to have run into problems with. And I don't even know if it would work.
[ March 05, 2007: Message edited by: Bear Bibeault ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://codingforums.com/archive/index.php?t-62435.html

Eric
 
Marc Luzietti
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric.
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic