//
</script>
127.模拟控件的单击事件
<INPUT TYPE="hidden" name="guoguo" onclick="haha()">
<script LANGUAGE="Javascript">
<!--
function haha()
{
alert();
}
guoguo.click();
//-->
</script>//
128.取出记录集的列名
java.sql.ResultSet rset = com.bsitc.util.DBAssist.getIT().executeQuery(queryStatement, conn);
java.sql.ResultSetMetaData metaData = rset.getMetaData();
int count = metaData.getColumnCount();
String name = metaData.getColumnName(i);
String value = rset.getString(i);//
129.格式化数字
function format_number(str,digit)
{
if(isNaN(str))
{
alert("您传入的值不是数字!");
return 0;
}
else if(Math.round(digit)!=digit)
{
alert("您输入的小数位数不是整数!");
return 0;
}
else
return Math.round(parseFloat(str)*Math.pow(10,digit))/Math.pow(10,digit);
}
130.回车按钮转化为tab按钮
if(event.keyCode==13) event.keyCode=9; //将
131.滚动条滚动
<button onclick="text1.scrollTop=text1.scrollHeight">Scroll</button><br>
<textarea id="text1" cols=50 rows=10>
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
</textarea>//
132.判断是什么对象
if(typeof(unknown)=="function")return true;
if(typeof(unknown)!="object")return false;//
133.取消文本框自动完成功能
<input type="text" autocomplete="off"> //
134.让下拉框自动下拉
<select onmouseover="javascript:this.size=this.length" onmouseout="javascript:this.size=1">
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select> //
135.读取XML文件
var childrenobj=myselect//document.all.myselect;
var ōXMLDoc = new ActiveXObject('MSXML');
oXMLDoc.url = "mymsg.xml";
var ōRoot=oXMLDoc.root;
if(oRoot.children != null)
{
for(var i=0;i<oRoot.children.item(0).children.length;++i)
{
ōItem = oroot.children.item(0).children.item(i);
ōOption = new Option(oItem.text,oItem.value);
childrenobj.add(oOption);
}
}
//mymsg.xml文件
<?xml version="1.0" encoding="gb2312" ?>
<childrenlist>
<aa>
<child value='3301'>杭州地区</child>
<child value='3303'>温州地区</child>
</aa>
<aa>
<child value='3310'>台州地区</child>
<child value='3311'>丽水地区</child>
</aa>
</childrenlist>//
136.点击图片,图片停止
<a href="javascript:"><img src="
/uploadfile/201005/26/8B84153775.gif" border="0"></a>//
137.显示本地计算机信息
var WshNetwork = new ActiveXObject("Wscript.Network");
alert("Domain = " + WshNetwork.UserDomain);
alert("Computer Name = " + WshNetwork.ComputerName);
alert("User Name = " + WshNetwork.UserName);//
138.比较时间
tDate = new Date(2004,01,08,14,35); //年,月,日,时,分
dDate = new Date();
tDate<dDate?alert("早于"):alert("晚于");//
139.弹出鼠标所在处的链结地址
<body onmouseover="if (event.srcElement.tagName=='A')alert(event.srcElement.href)"><a
href="
http://51js.com/viewthread.php?tid=13589&