不好意思,标题写错了
应该是 禁止查看页面代码,但是允许使用TextBox的右键功能,请问怎么实现

解决方案 »

  1.   

    如果是.net的话,把页面的代码全写到后台输出到页面,js代码做成js文件引用,
      

  2.   

    //方法一
    在 <body>与</body>之间加入:
    <script language="javascript">
    function click() {
    if (event.button==2) { 
    alert('去,不准偷看。')
    }
    }
    document.onmousedown=click
    </script>
    或 
    <script language="javascript"> 
    document.oncontextmenu=stop 
    </script>
    //方法二
    oncontextmenu='return false' 
    ondragstart='return false' 
    onselectstart ='return false' 
    onselect='document.selection.empty()' oncopy='document.selection.empty()' 
    onbeforecopy='return false' 
    onmouseup='document.selection.empty()'
    //jsp中禁用鼠标右键,禁止复制粘贴,双击鼠标滚动屏幕的代码
    onmouseup=document.selection.empty() 
    oncontextmenu="return false" 
    onselectstart="return false" 
    ondragstart="return false" 
    onbeforecopy="return false"
    onselectstart="return false" oncut="return false;" oncopy="return false;"
    leftMargin=0 topMargin=0 marginheight="0" marginwidth="0"
    oncopy=document.selection.empty() 
    leftMargin=0 
    topMargin=0 
    onselect=document.selection.empty()