javascript 问题 textarea不会显示,不管怎么样点都市不会显示。。哪里的问题啊。谢谢了
//js.jsfunctionmousestatus(e){if(!e)e=window.event;btn=e.button;whichone=(btn<2)?"Lef...
//js.js
function mousestatus(e){
if(!e)
e=window.event;
btn=e.button;
whichone=(btn<2)? "Left" : "Right";
message=e.type+":"+"+whichone+"\n";
document.form1.info.value+=message;
obj=document.getElementById("testlink");
obj.onmousedown=mousestatus;
obj.onmouseup=mousestatus;
obj.onclick=mousestatus;
obj.ondblclick=mousestatus;
}
//a.html
<!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="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<a href="#" id="testlink" >Test Link</a>
<form name="form1">
<textarea rows="10" cols="70" name="info" id="text" >asdasdadadadad</textarea>
</form>
<script language="javascript" type="text/javascript" src="js.js">
</script>
</body>
</html> 展开
function mousestatus(e){
if(!e)
e=window.event;
btn=e.button;
whichone=(btn<2)? "Left" : "Right";
message=e.type+":"+"+whichone+"\n";
document.form1.info.value+=message;
obj=document.getElementById("testlink");
obj.onmousedown=mousestatus;
obj.onmouseup=mousestatus;
obj.onclick=mousestatus;
obj.ondblclick=mousestatus;
}
//a.html
<!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="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<a href="#" id="testlink" >Test Link</a>
<form name="form1">
<textarea rows="10" cols="70" name="info" id="text" >asdasdadadadad</textarea>
</form>
<script language="javascript" type="text/javascript" src="js.js">
</script>
</body>
</html> 展开
2个回答
展开全部
没看到有任何地方分配了事件给mousestatus函数,也就是说没有任何地方能够调用这个函数。
试试把事件分配的代码放到函数外面:
function mousestatus(e){
if(!e)
e=window.event;
btn=e.button;
whichone=(btn<2)? "Left" : "Right";
message=e.type+":"+"+whichone+"\n";
document.form1.info.value+=message;
}
obj=document.getElementById("testlink");
obj.onmousedown=mousestatus;
obj.onmouseup=mousestatus;
obj.onclick=mousestatus;
obj.ondblclick=mousestatus;
试试把事件分配的代码放到函数外面:
function mousestatus(e){
if(!e)
e=window.event;
btn=e.button;
whichone=(btn<2)? "Left" : "Right";
message=e.type+":"+"+whichone+"\n";
document.form1.info.value+=message;
}
obj=document.getElementById("testlink");
obj.onmousedown=mousestatus;
obj.onmouseup=mousestatus;
obj.onclick=mousestatus;
obj.ondblclick=mousestatus;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询