<script>
function getEvent()
{
if(!(document.getElementById&& (navigator.appName=="Netscape"))) return window.event;
func=getEvent.caller;
while(func!=null){
var arg0=func.arguments[0];
if(arg0)
{
if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation))
{
return arg0;
}
}
func=func.caller;
}
return null;
}
//测试函数,打印所有event支持的属性,包括 clientX、target、srcElement等
function test(){
var evt = getEvent();
//(evt.srcElement || evt.target);
var html = '<ul>';
var text = '';
for(var i in evt){
try{
if(typeof(evt[i]) == 'object' && (i=='srcElement'||i=='target')){
html +='<li style="color:green">'+ i+':<ul>';
text +=''+i+':';
for(var ii in evt[i]){
try{
html +='<li>'+ ii+':'+evt[i][ii].toString()+'</li>';
text +=' '+ii+':'+evt[i][ii].toString()+"\r\n";;
}catch(E){
html +='<li>'+ii+':'+E.toString()+'</li>';
text +=' '+ii+':'+E.toString()+"\r\n";
}
}
html +='</ul></li>';
}else
html +='<li>'+ i+':'+evt[i]+'</li>';
text +=''+i+':'+evt[i]+"\r\n";;
}catch(E){
html +='<li>'+i+':'+E.toString()+'</li>';
text +=''+i+':'+E.toString()+"\r\n";
}
}
html += '</ul>';
document.getElementById('D1').innerHTML = html;
if(document.getElementById('D2').innerText)
document.getElementById('D2').innerText = text;
else document.getElementById('D2').innerHTML = text;
}
/**/
</script>
<div>
<table width="100%">
<tr>
<td>testCode
</td><td><input id="testID" value="Click Me!" type="button" onClick="test()">
</td>
</tr>
<tr>
<td width="50%" valign="top"><textarea style="width:100%" rows="30" id="D2">TEST</textarea></td>
<td width="50%"><div id="D1" style="overflow:auto; height:450px"></div></td>
</tr>
</table>
</div>
(责任编辑:最模板) |