例如 我按住Ctrl 然后鼠标经过一段文字,那么就触发一个js事件~单独一项的话就不触发实践!

解决方案 »

  1.   


    <script>
    function xx(){
       if(event.ctrlKey) alert("xxx");
    }
    </script>
    <body>
      <div onmouseover="xx()">xxxxxxxxxxxxx</div>
    </body>
      

  2.   

    function a(e){
    var event=e||window.event;
    if(event.ctrlKey){
    //your code here
    }
    }
      

  3.   

    if(event.ctrlKey) alert();    
      

  4.   

    支持ie和ff的<script>
    function xx(evt){
    evt = window.event?window.event:evt;
        if(evt.ctrlKey || evt.which==17) alert("xxx");
    }
    </script>
    <body>
      <div onmouseover="xx(event)">xxxxxxxxxxxxx</div>
    </body>
      

  5.   


    <script type="text/javascript">
    function fn(e){
    e = e || window.event;
    if (e.ctrlKey) {
    // your code
    }
    }
    </script>
    <body>
      <div onmouseover="fn(event)">test</div>    
    </body>