写一个HTML页面,实现以下功能,左键点击页面时显示“您好”,右键点击时显示“禁止右键”。并在2分钟后自动关闭页面。

解决方案 »

  1.   

    <script language="JavaScript">if (navigator.appName.indexOf("Internet Explorer") != -1) 
    document.onmousedown = noSourceExplorer;function noSourceExplorer()
    {
    if (event.button == 1)
    {
        //您好
    }
    if (event.button == 2 | event.button == 3)
    {
    alert("禁止右键");
    //两分钟关闭页面,可以用setTimeOut实现
    }
    }
    </script>
      

  2.   

    <script>
    document.onclick=function()
    {
      alert('您好');
    }
    document.oncontextmenu=function()
    {
      alert('禁止右键');return false;
    }
    </script>
    <body>
    AAA
    </body>
      

  3.   

    <script>
    document.onclick=function()
    {
      alert('您好');
    }
    document.oncontextmenu=function()
    {
      alert('禁止右键');
      window.setTimeout('window.opener=null;window.close()',1000);
      return false;
    }
    </script>
    <body>
    AAA
    </body>