0
使用select元素在我的应用程序,我们使用这个模式很多:停用文本选择,并与Firefox 40
<select name="select" onfocus=this.select; onClick=this.focus();>
<option value="value1" selected>Value 1</option>
<option value="value2">Value 2</option>
</select>
<script>
document.onmousedown = new Function("return false");
</script>
线document.onmousedown = new Function("return false");
旨在防止页面文本选择。不幸的是,它也阻止了mousedown事件传播到select元素。我们使用的workarround是回调onfocus=this.select; onClick=this.focus();
。
我的问题是,它不适用于Firefox 40:单击选择框什么也不做。 (与39正常工作)
我可以删除行document.onmousedown = new Function("return false");
来修复选择框,但它会允许在页面中选择文本。
我的问题是:我有哪些选项可以同时使用Firefox 40和工作选择框?
你不能只使用CSS? '-moz-user-select:none;用户选择:无;(和任何必需的供应商前缀) – CodingIntrigue
@Rraham Thx,我将重点关注如何处理select元素以搜索其他方式...... –