简体   繁体   English

文本选择Internet Explorer

[英]Text Selection Internet Explorer

I have tried with no success to disable text selection in this code. 我尝试在此代码中禁用文本选择没有成功。 EDIT(Thanks techfoobar): http://jsfiddle.net/5uG63/3/ The only element that I have applied the majority of the code to is the element that has the three in it. 编辑(感谢techfoobar): http : //jsfiddle.net/5uG63/3/我将大部分代码应用到的唯一元素是其中包含三个元素的元素。 The rest of them you will be able to highlight. 您将可以突出显示其中的其余部分。 I know none of the dragging functions work seeing this is a snippet of a much larger block of code that would be hard to post seeing it is getting the elements through Ajax. 我知道所有拖动功能都无法正常工作,因为看到这是一大段代码的一小段,如果看到它是通过Ajax获取元素,则很难发布。 I am not really worried about the users selecting the text for the sense of possibly taking the information, but sometimes when the text get selected it interferes with the drag and drop function. 我并不真正担心用户选择文本可能会获取信息,但是有时候选择文本时会干扰拖放功能。

For the element containing the three, and all the others when they are enabled, there seems to be only one case that this happens. 对于包含这三个元素的元素,以及启用它们后的所有其他元素,似乎只有一种情况发生。 Using Internet Explorer, if you were to click in the center of the white space between the two boxes at the far left side, and then drag your mouse across to the far right of the two boxes, the number 3 then becomes selected. 使用Internet Explorer,如果要单击最左侧两个框之间的空白区域的中心,然后将鼠标拖到两个框的最右侧,则数字3将变为选中状态。 I am using Internet Explorer 9. 我正在使用Internet Explorer 9。

I tried disabling it in the CSS, which seems to have little effect. 我试图在CSS中禁用它,似乎效果不大。 I think that the issue is that it is being selected from outside the div that it is in. 我认为问题在于它是从所在的div外部选择的。

That is the CSS that I used: How to disable text selection highlighting using CSS? 那就是我使用的CSS: 如何使用CSS禁用文本选择突出显示?

-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;

Thanks for your help! 谢谢你的帮助!

For your table, you have specified onselectstart="select()" . 对于您的表,您已经指定了onselectstart="select()" You should change this to onselectstart="return select()" (note the return ) to ensure that the false you are returning from the select() function is notified to the browser, which in turn blocks selection. 您应该将其更改为onselectstart="return select()" (注意return ),以确保将从select()函数返回的false通知浏览器,从而阻止选择。

Check this fiddle : http://jsfiddle.net/5uG63/4/ 检查此小提琴http : //jsfiddle.net/5uG63/4/

Note: This will work only if you start the selection from the element itself. 注意:仅当您从元素本身开始选择时,此方法才有效。 If you start selecting from outside your table, things will still get selected. 如果您从表格外部开始选择,则仍然会选择内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Internet Explorer中禁用了文本选择 - text selection disabled in internet explorer 在Internet Explorer中设置textarea选择 - Set textarea selection in Internet Explorer 在Internet Explorer中的ag-grid中移动行选择会选择其他文本 - Shift row selection in ag-grid in Internet Explorer selects additional text 为什么单击按钮而不是单击“ div”时,可以从textarea中选择文本(在Internet Explorer中) - Why getting a text selection from textarea works when a button clicked but not when a “div” clicked (in Internet Explorer) 在Internet Explorer中使用sprited按钮和selection.createRange()时获取所选文本时出现问题 - Problem getting selected text when using a sprited button and selection.createRange() in Internet Explorer 在VML和Internet Explorer中禁用图形元素选择 - Disabling graphic element selection in VML and Internet Explorer 下拉列表选择在Internet Explorer中无法正常工作 - Dropdown list selection not working properly in internet explorer 如何避免Internet Explorer的第一按钮选择? - How to avoid internet explorer first button selection? 文本在Internet Explorer中错误地换行 - Text wrapping incorrectly in Internet Explorer 在Internet Explorer 10中将文本保存在本地文件中 - Saving text in a local file in Internet Explorer 10
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM