简体   繁体   English

collpase在mozilla中不起作用,但在chrome中起作用

[英]collpase doesn't work in mozilla but works in chrome

Collapse doesn't seem to work in mozilla firefox but works perfectly in chrome.Here is an example 折叠似乎在mozilla firefox中似乎不起作用,但在chrome中效果很好。

 var r1 = window.getSelection().getRangeAt(0);
 var r2 = window.getSelection().getRangeAt(0);
 console.log(r1.collapsed);  // It is false Now
 console.log(r2.collapsed);  // It is false Now
 r1.collapse(true);

Now when you set the r1.collpase to true,r2.collapsed is set to true.But when you try set r2.collapse to false,it remains true. 现在,当您将r1.collpase设置为true时,r2.collapsed设置为true。但是当您尝试将r2.collapsease设置为false时,它仍然为true。

 r2.collapse(false);
 console.log(r2.collapsed); //true

I think this is a firefox bug.Correct me if i am wrong.Is there any workaround this in firefox? 我认为这是一个firefox错误。如果我错了,请纠正我.firefox中有任何解决方法吗?

For Firefox Selection Range https://developer.mozilla.org/en-US/docs/Web/API/Range/collapsed https://developer.mozilla.org/en-US/docs/Web/API/Range/collapse 对于Firefox选择范围https://developer.mozilla.org/en-US/docs/Web/API/Range/collapsed https://developer.mozilla.org/en-US/docs/Web/API/Range/collapse

The collapse parameters just say in which direction you want to collapse the selection. 折叠参数只是说出您要折叠选择的方向。 But after that, it's always collapsed. 但是在那之后,它总是崩溃了。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM