可能重複:
What is the best way to prevent highlighting of text when clicking on its containing div in javascript?從選擇的內容網頁上的Firefox停止
當用戶點擊並拖動你如何從突出自己的內容的firefox停止?
可能重複:
What is the best way to prevent highlighting of text when clicking on its containing div in javascript?從選擇的內容網頁上的Firefox停止
當用戶點擊並拖動你如何從突出自己的內容的firefox停止?
這一點已經在這裏找到答案: What is the best way to prevent highlighting of text when clicking on its containing div in javascript?
基本上,用於Firefox,你應該能夠做到這一點在CSS:
div.noSelect {
-moz-user-select: none;//mozilla browsers
-khtml-user-select: none;//webkit browsers
}
對於IE,你可以明顯地「添加一個處理程序的ondragstart事件,並返回false;「
如果您正在使用您的網頁上的jQuery UI,你可以簡單地使用$('body').disableSelection();
如果沒有,試試這個(這是disableSelection()
一樣):
var elem = document.body;
elem.onselectstart = function() { return false; };
elem.MozUserSelect = 'none';
elem.unselectable = 'on';
您可以用unselectable
做到這一點IE中的expando屬性和其他瀏覽器中的CSS。看到這個答案的詳細信息:How to disable text selection highlighting using CSS?
作爲@TheifMaster所說,我們知道你有多接受的答案,你做得越多,就越有可能的是,*聰明的傢伙*會給你一個答案。 (`smart!= nice`)您可以通過點擊* down vote *按鈕下方的**複選標記**來完成此操作。 – 2011-02-16 22:50:45