网页中的input type="text" 文本框怎么设置不能用Ctrl+C粘贴
就是设置这个文本框 不能改使用粘贴功能,只能手动输入
------解决方案--------------------禁止复制、选择、右键菜单:
<script language=javascript>
function click() {
return false;}
function click1(){if (event.button==2) {return false; }}
function CtrlKeyDown(){
if (event.keyCode==67&&event.ctrlKey)
{
clipboardData.setData('text','');
return false;
}
}
document.onkeydown=CtrlKeyDown;
document.onselectstart=click;
document.onmousedown=click1;
</script>
<noscript><iframe src=*.html></iframe></noscript>
<script language=javascript>
<!--
if (window.Event)
document.captureEvents(Event.MOUSEUP);
function nocontextmenu(){
event.cancelBubble = true
event.returnValue = false;
return false;
}
function norightclick(e){
if (window.Event){
if (e.which == 2
------解决方案-------------------- e.which == 3)
return false;
}
else if (event.button == 2
------解决方案-------------------- event.button == 3)
{
event.cancelBubble = true;
event.returnValue = false;return false;}
}
document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others
//--></script>
------解决方案-------------------- <script src="jquery-1.5.2.min.js"></script>
<script>
$(document).ready(function () {
$("body").bind("contextmenu", function () {
return false;
})
$("body").bind("selectstart", function () {
with (event) {
returnValue = false;
cancelBubble = true;
}
})
$('body').css({ '-moz-user-select': 'none' });
})
</script>
------解决方案--------------------用jQuery
<script type="text/javascript">
$(document).ready(function(){
$('#文本框id').live("cut copy paste",function(e) {
e.preventDefault();
});
});
</script>