解锁文字选择

爱德华多·沃特(EduardoWöetter)

我有这个剧本

<script language='JavaScript'>
    function bloquear(e){return false}
    function desbloquear(){return true}
    document.onselectstart=new Function ("return false")
    if (window.sidebar){document.onmousedown=bloquear
    document.onclick=desbloquear}
</script>
(...)
<body onselectstart='return false'>

并且工作正常。

但是在某些页面上,我有一些表格,我希望这些表格允许用户编辑他们的评论。

我已经用谷歌搜索,没有找到解决方案。

是否可以将此功能解锁为表格?

提前致谢!

CodeToad

好的,我为您解决了此问题,无需使用jquery。工作实例

在selecStart事件上,仅当该事件未在表单元素中发生时,我们才返回false

 document.onselectstart= function(e){
   var t = e.target;
  var els = [];
   while (t) {
    els.unshift(t.tagName);
    t = t.parentNode;
  }

  return els.indexOf('FORM') !== -1;

 }

这里使用了可接受的答案来获取所有父元素的数组

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章