1.文本框焦点问题
onblur:当失去输入焦点后产生该事件
onfocus:当输入获得焦点后,产生该文件
onchange:当文字值改变时,产生该事件
onselect:当文字加亮后,产生该文件
<input type="text" value="郭强" onfocus="if(value=='郭强') {value=''}" onblur="if
(value=='') {value='郭强'}">点击时文字消失,失去焦点时文字再出现
2.网页按钮的特殊颜色
<input type=button name="submit1" value="郭强" size=10 class=s02
style="background-color:rgb(235,207,22)">
3.鼠标移入移出时颜色变化
<input type="submit" value="找吧" name="b1" onmouseout=this.style.color="blue"
onmouseover=this.style.color="red" class="button">
4.平面按钮
<input type=submit value=订阅style="border:1px solid :#666666; height:17px; width:25pt; font-size:9pt;
background-color: #e8e8ff; color:#666666" name="submit">
5.按钮颜色变化
<input type=text name="nick" style="border:1px solid #666666; font-size:9pt; height:17px;
background-color: #f4f4ff; color:#ff6600" size="15" maxlength="16">
6.平面输入框
<input type="text" name="t1" size="20" style="border-style: solid; border-width: 1">
7.使窗口变成指定的大小
<script>
window.resizeto(300,283);
</script>
8.使文字上下滚动
<marquee direction=up scrollamount=1 scrolldelay=100 onmouseover='this.stop()' onmouseout='this.start()'
height=60>
<!-- head_scrolltext -->
<tr>
<td>
共和国
</table> <!-- end head_scrolltext -->
</marquee>
9.状态栏显示该页状态
<base onmouseover="window.status='网站建设http://www.webmake.cn/' ;return true">
10.可以点击文字实现radio选项的选定
<br>
<input type="radio" name="regtype" value="a03" id="a03">
<label for="a03"> 情侣: 一次注册两个帐户</label> <br>
11.可以在文字域的font写onclick事件
12.打印</a>打印网页
<a href="http://www.php1.cn/">
13.线型输入框
<input type="text" name="key" size="12" value="关键字" onfocus=this.select() onmouseover=this.focus()
class="line">
14.显示文档最后修改日期
<script language=javascript>
function hi(str)
{
document.write(document.lastmodified)
alert(hi+str+!)
}
</script>
15.可以在鼠标移到文字上时就触发事件
<html>
<head>
<script language="livescript">
<div id=a1></div>//
49.可以改变页面上的连接的格式,使其为双线
<style>
a:link {text-decoration: none; color:#0000ff; font-family: 宋体}
a:visited {text-decoration: none; color: #0000ff; font-family: 宋体}
a:hover {text-decoration: underline overline; color: ff0000}
</style>
<style>
a:link {text-decoration: none; color:#0000ff; font-family: 宋体}
a:visited {text-decoration: none; color: #0000ff; font-family: 宋体}
a:hover {text-decoration: underline overline line-through; color: ff0000}
th{font-size: 9pt}
td{font-size: 9pt}
body {scrollbar-face-color: #a9d46d; scrollbar-highlight-color: #e7e7e7;scrollbar-shadow-color:#e7e7e7;
scrollbar-3dlight-color: #000000; line-height: 15pt; scrollbar-arrow-color: #ffffff;
scrollbar-track-color: #e7e7e7;}
input{border-top-width: 1px; padding-right: 1px; padding-left: 1px; border-left-width: 1px; font-size:
9pt; border-left-color: #cccccc;
border-bottom-width: 1px; border-bottom-color: #cccccc; padding-bottom: 1px; border-top-color: #cccccc;
padding-top: 1px; height: 18px; border-right-width: 1px; border-right-color: #cccccc}
div,form ,option,p,td,br{font-family: 宋体; font-size: 9pt}
textarea, select {border-width: 1; border-color: #000000; background-color: #efefef; font-family: 宋体;
font-size: 9pt; font-style: bold;}
.text { font-family: 宋体; font-size: 9pt; color: #003300; border: #006600 solid; border-width: 1px 1px
1px 1px}
</style>完整的css
50.新建frame
<a
href="http://www.php1.cn/">
/a_13.html')><img alt=帮助border=0 src=http://up.2cto.com/2011/1114/20111114031136305.gif"></a>
51.向文件中写内容
<%@ page import="java.io.*" %>
<%
string str = "print me";
//always give the path from root. this way it almost always works.
string nameoftextfile = "/usr/anil/imp.txt";
try
{
printwriter pw = new printwriter(new fileoutputstream(nameoftextfile));
pw.println(str);
//clean up
pw.close();
}
catch(ioexception e)
{
out.println(e.getmessage());
}
%>
52.先读文件再写文件
<%@ page language = "java" %>
<%@ page contenttype = "text/html; charset=gb2312" %>
<%@ page import ="java.util.*" %>
<%@ page import ="java.lang.*" %>
<%@ page import ="javax.servlet.*" %>
<%@ page import ="javax.servlet.jsp.*" %>
<%@ page import ="javax.servlet.http.*" %>
<%@ page import="java.io.*" %>
eryrytry
<%
int count=0;
fileinputstream fi =new fileinputstream ("count.txt");
objectinputstream si= new objectinputstream (fi);
count =si.readint();
count++;
out.print(count);
si.close();
fileoutputstream fo =new fileoutputstream ("count.txt");
objectoutputstream so= new objectoutputstream (fo);
so.writeint(count);
so.close();
%>
53.直线型输入框
<input name=password size=10 type=password style="border-left-width: 0; border-right-width: 0;
border-top-width: 0; border-bottom-style: solid; border-bottom-width: 1; background-color: #9ceb9c">
54.可以将背景改为按钮性状,通过改变css改变属性
<td width="65" align="center" bgcolor="#e0e0e0" onmouseover=this.classname='mouseoverbt';
onmouseout=this.classname='mouseout';><a href="http://www.php1.cn/">
color=#000000>录音笔</font></a></td>
<style>
.mouseoverbt
{
background-image: url(http://www.yongle.com.cn/img/btbgw64h20y.gif);
background-repeat: no-repeat;
}
.mouseout
{
background-color: #e0e0e0;
}
</style>
55.同时按下ctrl和q键
document.onkeydown=function()
{
if(event.ctrlkey&&event.keycode==81)
{alert(1)}
}//
56.以下是一个完整的显示hint的代码,其思想是当鼠标停留是将div中的内容显示在鼠标出,当鼠标移出后在将该div隐
藏掉
---------------------------------------------------------------------------------------------------------
------------
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<style>
#hint{
width:198px;
border:1px solid #000000;
background:#99ff33;
position:absolute;
z-index:9;
padding:6px;
line-height:17px;
text-align:left;
top: 1520px;
}
</style>
<script language="javascript">
<!--
function showme()
{
var oson=window.document.getelementbyidx_x("hint");
if (oson==null) return;
with (oson)
{
innertext=guoguo.value;
style.display="block";
style.pixelleft=window.event.clientx+window.document.body.scrollleft+6;
style.pixeltop=window.event.clienty+window.document.body.scrolltop+9;
}
}
function hidme()
{
var oson=window.document.getelementbyidx_x("hint");
if (oson==null) return;
oson.style.display="none";
}
//-->
</script>
<body>
<text id=guoguo value=ga>
<a href="http://www.php1.cn/">
<div id=hint style="display:none"></div>
</body>
</html>
---------------------------------------------------------------------------------------------------------
------------
57.弹出窗口
方法一:<body onload="openwen()"> 浏览器读页面时弹出窗口;
方法二:<body onunload="openwen()"> 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:<a href="http://www.php1.cn/">
注意:使用的#是虚连接。
方法四:用一个按钮调用:<input type="button" onclick="openwin()" value="打开窗口"> 何时装载script
58.动态改变字体的大小
function dozoom(size)
{
document.getelementbyidx_x('zoom').style.fontsize=size+'px'
}
function aa()
{
var newwin=window.open(url);
newwin.document.form1.text1.value=value1;
}改变弹出窗口上域的属性
opener.document.form2.text2.value=value2;改变父窗口的域的值
59.判断是何种浏览器
var name = navigator.appname;
if (name == microsoft internet explorer)
alert(ie);
else if (name == netscape)
alert(ns);//
60.vbsscript确定框
<script language="vbscript">
<!--
msgbox "确定删除吗?", 4
//-->
</script>//
61.复制内容到剪切板
function jm_cc(bb)
{
var ob=eval_r(document.form1.+bb);
ob.select();
js=ob.createtextrange();
js.execcommand(copy);
}//
62.java中建立数据库连接取数据
public void init()
{
string url=jdbc:odbc:javadata;
try
{
class.forname(sun.jdbc.odbc.jdbcodbcdriver);
connection con=drivermanager.getconnection(url,sa,);//mssql database user sa and password
databasemetadata dma=con.getmetadata();
system.out.println(connect to+dma.geturl());
system.out.println(;driver +dma.getdrivername());
system.out.println(;version +dma.getdriverversion());
system.out.println();
statement stmt=con.createstatement();
resultset rs=stmt.executequery(select * from company.dbo.tb_name where number=1);//sql
rs.next();
string dispresult=rs.getstring(name);
system.out.println(dispresult);// instead,you can display it in paint() or use awt etc.
rs.close();
stmt.close();
con.close();
}
catch(sqlexception ex)
{
system.out.println(!!!sql exception !!!);
while(ex!=null)
{
system.out.println(sqlstate:+ex.getsqlstate());
system.out.println(message:+ex.getmessage());
system.out.println(vendor:+ex.geterrorcode());
ex=ex.getnextexception();
system.out.println();
}
}
catch(java.lang.exception ex)
{
ex.printstacktrace();
}
}//
63.最小化窗口
window.blur()//
64.文档的路径
document.url//
65.定时执行某段程序
settimeout(change_color(),600);
66.设置为主页
function makehome(){
netscape.security.privilegemanager.enableprivilege(universalpreferenceswrite);
navigator.preference(browser.startup.homepage, location.href);
}//
67.设置为收藏
function addfav(){
if(ie)
window.external.addfavorite(location.href,'www.ogrish.com : grotesque movies and pictures');
if(ns)
alert(thanks for the bookmark!/n/nnetscape users click ok then press ctrl-d);
}//
68.判断cookie是否可用
navigator.cookieenabled;//
69.显示有模式的有页面的弹出窗口
function setbgcolor_onclick()
{
var color = showmodaldialog(/mailpage/compose/colorsel.html,0,help=0);
if (color != null)
{
document.compose.bgcolor.value = color;
}
}//
70.截取小数点后两位
var a=3454545.4454545;
alert(a.tofixed(2));//
71.禁止选择页面上的文字来拷贝
<script>
function noeffect() {
with (event) {
returnvalue = false;
cancelbubble = true;
}
return;
}
</script>
<body onselectstart="noeffect()" oncontextmenu="noeffect()">//
72.屏蔽右键菜单
oncontextmenu=event.returnvalue = false//
73.事件禁止起泡
event.cancelbubble = true//
74.禁止在输入框打开输入法
<input style="ime-mode: disabled">//
75.屏蔽汉字和空格
<input name="txt"><input type="submit" onclick="alert(!/[^ -}]|/s/.test(txt.value))">//
76.用javascript判断文件是否存在
function exists(filespec)
{
if (filespec)
{
var fso;
fso = new activexobject(scripting.filesystemobject);
alert(fso.fileexists(filespec));
}
}
选择图片<input type=file name=f1><p>
<input type="submit" onclick="exists(f1.value)">//
77.获得当前的文本框选中的文字
<input onmouseup="alert(document.selection.createrange().text)" value=123>//
78.跳转至目标页面,同时不可返回
<a href="http://www.php1.cn/">
79.获得当前的行是表格的第几行
<script>
function getrow(obj)
{
if(event.srcelement.tagname==td){
currow=event.srcelement.parentelement;
alert(这是第+(currow.rowindex+1)+行);
}
}
</script>
<table border="1" width="100%" onclick=getrow(this)>
<tr>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
</tr>
<tr>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
<td width="20%"> </td>
</tr>
</table>//
80.删除表格某行,xx表示某行,下标从0开始计算
document.all.mytable.deleterow(xx)//
81.动态的向表格中添加行
<table id="t1" border="1">
</table>
<script language="javascript">
function add()
{
t1.insertrow().insertcell().innerhtml = '<input name="test'+t1.rows.length+'">';
}//
82.event.x,event.clientx,event.offsetx区别:
x:设置或者是得到鼠标相对于目标事件的父元素的外边界在x坐标上的位置。clientx:相对于客户区域的x坐标位置,不
包括滚动条,就是正文区域。offsetx:设置或者是得到鼠标相对于目标事件的父元素的内边界在x坐标上的位置。
screenx:相对于用户屏幕。
83.显示是鼠标按钮的哪个
<body onmousedown="alert(event.button)">点mouse看看//
84.打开c盘
<form action="file:///c|/"><input type="submit" value="c:/ drive"></form>//
85.当前屏幕的分辨率
screen.width、screen.height//
86.设置表格中的内容
tbl.rows[0].cells[1].innertext=document.form.text1.value;//
87.本地快捷键
<p><a href="http://www.php1.cn/">
<p><a href="http://www.php1.cn/">
<p><a href="http://www.php1.cn/">
<p><a href="http://www.php1.cn/">
<p><a href="http://www.php1.cn/">
target=_blank>控制面板</a></p>
<p><a href="http://www.php1.cn/">
88.ie菜单
<button onclick="min.click()"><font face="webdings">0</font></button>//改变按钮上的图片
<input type=button onclick="document.execcommand('createlink','true','true')"> //创建新连接
<input type=button onclick="document.execcommand('print','true','true')"> //打印
<input type=button onclick="document.execcommand('saveas','true','网站制作.htm')">//另存为htm
<input type=button onclick="document.execcommand('saveas','true','网站制作.txt')">//另存为txt
document.execcommand(saveas)//保存为
document.execcommand('undo')//撤销上一次操作
89.web对话框
<script>
var contents='<style>body,td{font:menu}img{cursor:hand}</style>';
contents+='<title>你要关闭我吗</title>';
contents+='<body bgcolor=menu>';
contents+='<table width=100% height=100% border=0>';
contents+='<tr><td align=center>';
contents+='你要关闭我吗?<br>';
contents+='<img src=dark.gif onclick=self.close() alt="...关闭">';
contents+='<img src=jet.gif onclick=self.close() alt="全是关闭">';
contents+='</td></tr></table>';
showmodaldialog(about:+contents+,,dialogheight:50px;dialogwidth:250px;help:no;status:no)
document.write(contents);
</script>//
90.取第x,y的值
<button onclick="t1.rows[x].cells[y].innertext='guoguo'"></button>//
91.向新打开的网页上写内容
newwin=window.open('about:blank','','top=10');
newwin.document.write('');//
93.返回
javascript:history.go(-2);//
94.将页面上选中的内容复制到剪贴板
abcdefg
<input type='button'
onclick="window.clipboarddata.setdata('text',document.selection.createrange().text);" value='复制页面选中
的字符'>//
95.将页面上选中的内容复制到剪贴板
<input type="text" name="">kjhkjhkhkj<input type="button" onclick="document.execcommand('copy', 'false',
null);">////
96.鼠标移到下拉框时自动全部打开
<select onmouseover="javascript:this.size=this.length" onmouseout="javascript:this.size=1"></select>//
97.获得本机的文件
var fso = new activexobject(scripting.filesystemobject);
var f1 = fso.getfile(c://bsitcdata//ejbhome.xml);
alert(file last modified: + f1.datelastmodified); //
98.判断客户端是否是ie浏览器
因为document.all 是ie 的特有属性,所以通常用这个方法来判断客户端是否是ie浏览器,document.all?1:0;
99.创建新的下拉框选项
new option(text,value)这样的函数//
100.在页面上画柱状图
<style>
td{font-size:12px}
body{font-size:12px}
v/:*{behavior:url(#default#vml);} //这里声明了v作为vml公用变量
</style>
<script language="javascript">
mathstr=12;
document.write (<v:rect fillcolor='red'
style='width:20;color:navy;height:"+5000/(1000/mathstr)+"'><br> %+mathstr+<br>4人<v:extrusion
backdepth='15pt' on='true'/></v:rect>)
</script>
<v:rect fillcolor='red' style='width:20;color:navy;height:200'><br><br>4人<v:extrusion
backdepth='15pt' on='true'/></v:rect>
<v:rect fillcolor='yellow' style='width:20;color:navy;height:100'><br><br>4人<v:extrusion
backdepth='15pt' on='true'/></v:rect>//
101.饼图
<style>
v/:* { behavior: url(#default#vml) }
o/:* { behavior: url(#default#vml) }
.shape { behavior: url(#default#vml) }
</style>
<script language="javascript">
function show(pie)
{
pie.strokecolor=pie.fillcolor;
pie.strokeweight=10;
div1.innerhtml=<font size=2 color=red> + pie.id +</font> <font size=2> + pie.title + </font>;
}
function hide(pie)
{
pie.strokecolor=white;
pie.strokeweight=1;
div1.innerhtml=;
}
</script>
</head>
<body>
<v:group style='width: 5cm; height: 5cm' coordorigin='0,0' coordsize='250,250'>
<v:shape id='asp技术' style='width:10;height:10;top:10;left:0' title='得票数:6 比例:40.00%'
onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">
coordsize='10,10' strokecolor='white' fillcolor='#ffff33'><v:path v='m 300,200 ae
300,200,200,150,0,9437184 xe'/></v:shape>
<v:shape id='php' style='width:10;height:10;top:10;left:0' title='得票数:1 比例:6.67%'
onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">
coordsize='10,10' strokecolor='white' fillcolor='#ff9933'><v:path v='m 300,200 ae
300,200,200,150,9437184,1572864 xe'/></v:shape>
<v:shape id='jsp' style='width:10;height:10;top:10;left:0' title='得票数:2 比例:13.33%'
onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">
coordsize='10,10' strokecolor='white' fillcolor='#3399ff'><v:path v='m 300,200 ae
300,200,200,150,11010048,3145728 xe'/></v:shape>
<v:shape id='c#写的.netweb程序' style='width:10;height:10;top:10;left:0' title='得票数:3 比例:20.00%'
onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">
coordsize='10,10' strokecolor='white' fillcolor='#99ff33'><v:path v='m 300,200 ae
300,200,200,150,14155776,4718592 xe'/></v:shape>
<v:shape id='vb.net写的.netweb程序' style='width:10;height:10;top:10;left:0' title='得票数:2 比例:13.33%'
onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">
coordsize='10,10' strokecolor='white' fillcolor='#ff6600'><v:path v='m 300,200 ae
300,200,200,150,18874368,3145728 xe'/></v:shape>
<v:shape id='xml技术' style='width:10;height:10;top:10;left:0' title='得票数:1 比例:6.67%'
onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">
coordsize='10,10' strokecolor='white' fillcolor='#ff99ff'><v:path v='m 300,200 ae
300,200,200,150,22020096,1572864 xe'/></v:shape>
</v:group>
<v:group style='width: 6cm; height: 6cm' coordorigin='0,0' coordsize='250,250'>
<v:rect style='height:10;width:15;top:0;left:10' fillcolor='#ffff33'/>
<v:rect style='height:28;width:100;top:0;left:30' stroked='false'><v:textbox
style='fontsize:2'>asp技术</v:textbox/></v:rect>
<v:rect style='height:10;width:15;top:30;left:10' fillcolor='#ff9933'/>
<v:rect style='height:28;width:100;top:30;left:30' stroked='false'><v:textbox
style='fontsize:2'>php</v:textbox/></v:rect>
<v:rect style='height:10;width:15;top:60;left:10' fillcolor='#3399ff'/>
<v:rect style='height:28;width:100;top:60;left:30' stroked='false'><v:textbox
style='fontsize:2'>jsp</v:textbox/></v:rect>
<v:rect style='height:10;width:15;top:90;left:10' fillcolor='#99ff33'/>
<v:rect style='height:28;width:100;top:90;left:30' stroked='false'><v:textbox
style='fontsize:2'>c#写的.netweb程序</v:textbox/></v:rect>
<v:rect style='height:10;width:15;top:120;left:10' fillcolor='#ff6600'/>
<v:rect style='height:28;width:100;top:120;left:30' stroked='false'><v:textbox style='fontsize:2'>vb.net
写的.netweb程序</v:textbox/></v:rect>
<v:rect style='height:10;width:15;top:150;left:10' fillcolor='#ff99ff'/>
<v:rect style='height:28;width:100;top:150;left:30' stroked='false'><v:textbox style='fontsize:2'>xml技术
</v:textbox/></v:rect>
</v:group>
<div style="position: absolute; left: 10; top: 10; width: 760; height:16">
<table border="1" cellpadding="2" cellspacing="2" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#cccccc" width="100%" id="table1">
<tr>
<td width="100%" id=div1> </td>
</tr>
</table>
</div>//
102.是一个特殊的容器,想装个网页都行
<button><iframe src="http://www.google.com/"></iframe></button>//button
103.外部的html代码
event.srcelement.outerhtml//
104.标识当前的ie事件的触发器
event.srcelement和event.keycode//
105.事件类型
event.type//
106.动态改变类型
<style>
.overnone { border-width:0;background-color:darkblue;cursor:default;color:gold;width:115}
.outnone {border-width:0;background-color:white;cursor:default;width:115}
</style>
<input class=outnone onmouseover=this.classname='overnone' >//
107.页面翻转
<html dir=rtl></html>//
108.滚屏
parent.scroll(x,y);//
<body onload="s=0" ondblclick="s=setinterval('scrollby(0, 1)',10)" onclick="clearinterval(s)">//
109.改变状态栏
self.status =;//
110.改变窗口大小
window.resizeto(200,300);//
111.改变鼠标样式
style
body{cursor: url('mouse.ani');
scrollbar-base-color: #506aa8;
scrollbar-arrow-color: #14213f;
}//
112.背景透明
<input type="button" value="button" style="background-color: transparent; border: 0;">//
113.鼠标为等待形状
<input type=button onclick="this.style.cursor='wait'">//
114.调用父窗口的函数
opener.fucntion1();//
115.body的内部html代码
<input type="button" onclick="alert(code.document.body.innerhtml)" value="查看">//
116.框架中调用父窗口的函数
<input type='button' onclick='parent.test();' value='调用parent窗口的函数'>//
117.交换节点
<table width=200 height=200 border>
<tr><td id=c1>cell_1</td></tr>
<tr><td id=c2>cell_2</td></tr>
</table>
<br>
<input type="button" value="swap row" onclick="c1.swapnode(c2)">//
118.删除节点
<table width=200 height=200 border>
<tr id=trall><td id=c1>cell_1</td></tr>
<tr><td id=c2>cell_2</td></tr>
</table>
<br>
<input type="button" value="swap row" onclick="trall.removenode(c2)">//
119.添加节点
addnode()//
120.获得事件的父与子标签
event.srcelement.children[0]和event.srcelement.parentelement //
121.集中为按钮改变颜色
<style>
button{benc:expression_r(this.onfocus = function(){this.style.backgroundcolor='#e5f0ff';})}
</style>
<button>new</button>//
122.判断是左键还是右键被按下
<body onmousedown=if(event.button==1)alert("左键");if(event.button==2)alert("右键")>//
123.获得操作系统的名称和浏览器的名称
document.write(navigator.useragent)//
124.alt/ctrl/shift键按下
event.altkey //按下alt键
event.ctrlkey //按下ctrl键
event.shiftkey //按下shift键
125.将当前位置定位为c盘。
{window.location=c:}//
126.返回输入框的类型
<script>
alert(event.srcelement.type);//
</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" > //
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 oxmldoc = new activexobject('msxml');
oxmldoc.url = mymsg.xml;
var oroot=oxmldoc.root;
if(oroot.children != null)
{
for(var i=0;i<oroot.children.item(0).children.length;++i)
{
oitem = oroot.children.item(0).children.item(i);
ooption = 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="http://www.php1.cn/">
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://www.php1.cn/">
140.注意不能通过与undefined 做比较来测试一个变量是否存在,虽然可以检查它的类型是否为“undefined”。在以
下的代码范例中,假设程序员想测试是否已经声明变量x :
// 这种方法不起作用
if (x == undefined)
// 作某些操作
// 这个方法同样不起作用- 必须检查
// 字符串undefined
if (typeof(x) == undefined)
// 作某些操作
// 这个方法有效
if (typeof(x) == undefined)
// 作某些操作
141.创建具有某些属性的对象
var myobject = new object();
myobject.name = james;
myobject.age = 22;
myobject.phone = 555 1234;//
142.枚举(循环)对象的所有属性
for (var a in myobject)
{
// 显示the property 'name' is james,等等。
window.alert(the property ' + a + ' is + myobject[a]);
}//
143.判断一个数字是否是整数
var a=23.2;
alert(a%1==1)//
144.新建日期型变量
var a = new date(2000, 1, 1);
alert(a.tolocaledatestring());
145.给类定义新的方法
function trim_1()
{
return this.replace(/(^/s*)|(/s*$)/g, );
}
string.prototype.trim=trim_1;
alert('cindy'.trim());
146.定义一个将日期类型转化为字符串的方法
function guoguo_date()
{
var tmp1,tmp2;
tmp1 =this.getmonth()+1+;
if(tmp1.length<2)
tmp1="0"+tmp1;
tmp2 =this.getdate()+"";
if(tmp2.length<2)
tmp2="0"+tmp2;
return this.getyear()+"-"+tmp1+"-"+tmp2;
}
date.prototype.tolitestring=guoguo_date;
alert(new date().tolitestring())
147. pasta 是有四个参数的构造器,定义对象。
function pasta(grain, width, shape, hasegg)
{
// 是用什么粮食做的?
this.grain = grain;
// 多宽?(数值)
this.width = width;
// 横截面形状?(字符串)
this.shape = shape;
// 是否加蛋黄?(boolean)
this.hasegg = hasegg;
//定义方法
this.tostring=aa;
}
function aa()
{
;
}
//定义了对象构造器后,用new 运算符创建对象实例。
var spaghetti = new pasta("wheat", 0.2, "circle", true);
var linguine = new pasta("wheat", 0.3, "oval", true);
//补充定义属性,spaghetti和linguine都将自动获得新的属性
pasta.prototype.foodgroup = "carbohydrates";
148.打印出错误原因
try
{
x = y // 产生错误。
}
catch(e)
{
document.write(e.description) //打印"'y' is undefined".
}//
149.生成excel文件并保存
var excelsheet;
excelapp = new activexobject("excel.application");
excelsheet = new activexobject("excel.sheet");
//本代码启动创建对象的应用程序(在这种情况下,microsoft excel 工作表)。一旦对象被创建,就可以用定义的对
象变量在代码中引用它。 在下面的例子中,通过对象变量excelsheet 访问新对象的属性和方法和其他excel 对象,
包括application 对象和activesheet.cells 集合。
// 使excel 通过application 对象可见。
excelsheet.application.visible = true;
// 将一些文本放置到表格的第一格中。
excelsheet.activesheet.cells(1,1).value = "this is column a, row 1";
// 保存表格。
excelsheet.saveas("c://test.xls");
// 用application 对象用quit 方法关闭excel。
excelsheet.application.quit();//
150.根据标签获得一组对象
var coll = document.all.tags("div");
if (coll!=null)
{
for (i=0; i<coll.length; i++)
...
}//
151.实现打印预览及打印
<object classid="clsid:8856f961-340a-11d0-a96b-00c04fd705a2" height=0 id=wb name=wb width=0></object>
<input type=button value=打印预览onclick="wb.execwb(7,1)">
<input type=button onclick=document.all.wb.execwb(6,1) value="打印">//
152.不通过form,直接通过名字引用对象
<input type="text" name="gg" value=aaaaa>
<script language="javascript">
<!--
alert(document.all.gg.value)
//-->
</script>//
153.使鼠标滚轮失效
function document.onmousewheel()
{
return false;
}//
154.创建弹出窗口
<script language="jscript">
var opopup = window.createpopup();
var opopupbody = opopup.document.body;
opopupbody.innerhtml = display some <b>html</b> here.;
opopup.show(100, 100, 200, 50, document.body);
</script>//
155.取得鼠标所在处的对象
var obj = document.elementfrompoint(event.x,event.y);//
156.获得左边的对象
<input type="text" name="gg"><input type="text" name="bb"
onclick="this.previoussibling.value='guoguo'">//
157.定位鼠标
document.all.hint_layer.style.left = event.x+document.body.scrollleft+10;
document.all.hint_layer.style.top = event.y+document.body.scrolltop+10;//
158.向下拉框指定位置添加项目
var op = document.createelement_x(option);
document.all.selected_items.children(index).insertadjacentelement(beforebegin,op);
op.text = document.all.all_items[i].text;
op.value = document.all.all_items[i].value;//
159.判断一个窗口是否已经打开,如果已经打开,则关闭之
var a;
if(a)
a.close();
else
a=window.open('','','');//
160.动态创建一个标签
newelem = document.createelement_x(div);
newelem.id = hint_layer;
document.body.appendchild(newelem);
document.all.hint_layer.innertext=guoguo;//
161.标题栏
document.title//
162.背景图片
<body style="background-attachment: fixed" background="img/bgfix.gif" ></body>//背景图片不动
<style type="text/css">
<!--
body {background-image:img/bgchild.jpg;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;}
-->
</style>//背景图片居中
163.设置透明效果
document.form.xxx.filters.alpha.opacity=0~100//
164.定义方法
var dragapproved=false;
document.onmouseup=new function(dragapproved = false);//