用 obj.onmouseover(); 试试看。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>试试</title>
</head><style type="text/css">
#txt {
width: 100px;
height: 50px;
border: 1px solid black;
}
</style><script type="text/javascript">
window.onload = function() {
var t = document.getElementById('txt');
t.onmouseover();
}
</script><body>
<div id="txt" onmouseover="alert('abc')">
abadfasw
</div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>试试</title>
</head><style type="text/css">
#txt {
width: 100px;
height: 50px;
border: 1px solid black;
}
</style><script type="text/javascript">
window.onload = function() {
var t = document.getElementById('txt');
t.onmouseover();
}
</script><body>
<div id="txt" onmouseover="alert('abc')">
abadfasw
</div>
</body>
</html>
解决方案 »
- 打开网站输入以下任意关键词搜索的代码
- js控制html5 video标签中视频的播放和停止
- 请问,如何在页面onload事件中获取事件对象
- 初来乍到,帮帮忙!(JSP)
- lhgcore -> lhgdialog弹出窗口等组件更新(2009-9-10)
- 请各位大侠帮忙:在javascrit中读取word文档内容的问题!
- jquery操作表格 添加行 删除行的浏览器兼容性问题
- 求(通用的)表单所有项必填的javascript代码,越简洁越好。
- 请问网站每行文字下面自动加一条虚线是怎么实现的
- *************jsp和js高手请进,关于servlet********************
- javascript 跨网域读数据
- 心情好 散分
<script type="text/javascript">
function f()
{
var t = document.getElementById('txt');
t.onmouseover();
}
</script><body>
<div id="txt" onmouseover="alert('abc')">
abadfasw
</div>
<button id="btn1" onclick="f()">click</button>
</body>
<html>
<script type="text/javascript">
var timer=null
function move(){
document.getElementById("d").style.left=parseInt(document.getElementById("d").style.left)+5
}
function moveStart(){
if(timer==null)
timer=setInterval("move()",100)
}
function moveStop(){
if(timer!=null)
clearTimeout(timer)
timer=null
}
</script><body>
<div id="txt" onmouseover="moveStart()" onmouseout="moveStop()">
鼠标移上来试试
</div>
<div id="d" style="position:absolute;left:100px;top:200px;background-color:Red">sdfsdsd</div>
<input type="button" onclick="document.getElementById('txt').onmouseover()" value="开始">
<input type="button" onclick="document.getElementById('txt').onmouseout()" value="停止">
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head> <body>
<div id="demo" style="background-color:#eee; border:1px solid #ccc;">
<a href="#">This is a link </a>
<span>This is a plain text </span>
<img src="../../JS/practice/20070120114354739.jpg" width="200" height="150"/>
</div>
<script type="text/javascript" language="javascript">
document.getElementById("demo").onmouseover = function(mEvent){
var obj;
if (typeof(event) != "undefined"){ // 判断是否为IE浏览器
obj = event.srcElement;
}else{
obj = mEvent.target;
} var o = window.event.fromElement;
while( o ){
if( o == document.getElementById("demo")){
o = window.event.toElement;
while( o ){
if( o == document.getElementById("demo")){
return;
}
o = o.parentNode;
}
break;
}
o = o.parentNode;
}
alert("Mouse over");
}
</script>
</body>
</html>
window.onload = function() {
var t = document.getElementById('txt');
t.onmouseover();
}
</script>
正解~!·1