1

I'm developing a Javascript slider that implements back/forward arrows for navigation. My problem is that rapidly clicking the 'Forward' arrow selects text. (Though for some reason this doesn't happen when rapidly clicking any of my other buttons.) I basically have the same problem as the OP in [this][1] question, but none of the answers work for me. I don't have the option of using <button>'s, I even tried it and it didn't work.

HellaMad
  • 5,294
  • 6
  • 31
  • 53

4 Answers4

2

I believe that adding this to your css should do the work:

a.someClass { 
-webkit-touch-callout: none; 
-webkit-user-select: none; 
-khtml-user-select: none; 
-moz-user-select: none; 
-ms-user-select: none; 
user-select: none; 
}
Bart Az.
  • 1,644
  • 1
  • 22
  • 32
  • This works great and has the added bonus that I can apply this fix on sites that aren't mine (looking at you GoG) by using a plugin to add CSS to the page. Thanks a lot! – Vala Jun 21 '14 at 11:20
2

I think you just want to disable the selection of text which can be done like the accepted answer in this question How to disable text selection using jQuery?

or if you're using jQueryUI you can just do

$('#mydiv').disableSelection();
Community
  • 1
  • 1
dstarh
  • 4,976
  • 5
  • 36
  • 68
1

Instead of making the arrow images the background for the <a> items, try actually placing the <img>s inside of the <a> tags. I believe the problem is that the browser thinks you're clicking on the background - which you effectively are - and many clicks on the background highlights text.

You said you don't have the option of using <button> -- What other limitations are we working with?

Tim
  • 14,447
  • 6
  • 40
  • 63
1

You can disable your link for a little time:

//Change image
//Disable the link (the arrow)
setTimeout(function()
    {
    //Enable your link
    }, 300); //300 is a time in ms

A plugin of JQuery allows you to disable/enable pretty much any field in the page: http://plugins.jquery.com/project/jqueryenabledisable

STM
  • 954
  • 6
  • 16