Discuti il tutorial sul forum !

Disabilitare la selezione di un testo

By default, web browsers display a text selection cursor over every visible text node in the HTML DOM, and users can select, copy, and paste any text on a web page. This is not appropriate for many Ajax applications, particularly if they involve drag-and-drop functionality that interferes with the web browser’s normal text selection facilities. This simple function disables text selection within a DOM node in all modern browsers:

function disableSelection(element) {
    element.onselectstart = function() {
        return false;
    };
    element.unselectable = "on";
    element.style.MozUserSelect = "none";
    element.style.cursor = "default";
}

You can’t disable text selection with CSS alone, unfortunately, because returning false from the onselectstart event is necessary to disable selection in Internet Explorer. Changing the cursor to "default" is not necessary to disable selection, but, without it, browsers will still display the text selection cursor over the unselectable text, which is confusing to end users.

Fonte: http://ajaxcookbook.org/disable-text-selection/

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati


Correlati


Commenti

Scrivi un commento





Commenti recenti:


Ultimi dal forum

Selezionando contrassegno si aggiungono spese al totale
Ho inserito postepay come pagamento
Inserire metakeywords
Problemi di installazione
Scaricare correttore ortografico italiano
Vari problemi
Installazione su server remoto
Installazione
Problema aggiornamento quantità prodotti carrello
Info
Bug utente + suggerimento formattazione
Problema cancellazione dalla mailing list
Problemi login
Problemi di visualizzazione nella home page
Fireworks appiattisce livelli quando salvo in png