当我们已经在html页面中设置了onselectstart="return false;"时,是否有人知道如何使用javascript选择特定的div(复制/粘贴)

    <head>
           <script type="text/javascript">

                function DisableSelection(){
                    var srcType = event ? ( event.srcElement ? event.srcElement.tagName: null ) : null;
                        if(srcType && ( srcType == "text" || srcType == "textarea" ) )
                        {
                        return true;
                        }
                    return false;

                    }

            </script>
    </head>

<body onContextMenu="return false" onselectstart="return DisableSelection();"/>

最佳答案

[DIV].onselectstart="";
[DIV].oncontextmenu="";

编辑:
刚刚意识到这可能是你的网页。。。
function canSelect(e)
{
    e=e?e:event;
    if(e.stopPropagation) e.stopPropagation();
    else e.cancelBubble=true;
    return true;
}

然后使用
[DIV].onselectstart=canSelect;


<div onselectstart="return canSelect(event);">

关于javascript - 如何使用JavaScript使特定的div可选(复制/粘贴)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12154130/

10-12 12:19
查看更多