• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stop text select on click

 
Marc Luzietti
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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 ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
 
Marc Luzietti
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eric.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic