整理自:http://topic.csdn.net/u/20091125/14/f7fd42d7-fb20-4acc-9623-3f5640c19411.html

比如:按住鼠标左键进行文本选定操作;鼠标写字等。

Click_Me 提供以下代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="  http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="textml; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<div >按住鼠标移上来</div>
<script type="text/javascript">
<!--
    var isBound = false;
    document.onmousedown = function(){
        isBound = true;
    }
    document.onmouseup = function(){
        isBound = false;
    }
    document.getElementById('odiv').onmouseover = function(){
        if(!!isBound)  this.style.backgroundColor = 'blue';
    }
//-->
</script>
</body>
</html>

其实,给控件绑定onmouseover事件,如果页面上多个控件需要此功能的话,就很麻烦。可以设置document.onmouseover事件,并通过window.event.srcElement(firefox下是event.target)当前事件的元素,来给当前控件提供功能。

相关文章:

  • 2022-12-23
  • 2021-04-27
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-10
  • 2021-06-28
  • 2021-09-21
  • 2021-04-29
  • 2021-12-20
  • 2022-12-23
相关资源
相似解决方案