dede做的网站怎样去换模版,网络培训总结,网站更换备案,html5的广泛应用1.文本框焦点问题onBlur:当失去输入焦点后产生该事件onFocus:当输入获得焦点后#xff0c;产生该文件Onchange:当文字值改变时#xff0c;产生该事件Onselect:当文字加亮后#xff0c;产生该文件 input typetext value郭强 οnfοcusif(v…1.文本框焦点问题onBlur:当失去输入焦点后产生该事件onFocus:当输入获得焦点后产生该文件Onchange:当文字值改变时产生该事件Onselect:当文字加亮后产生该文件 input typetext value郭强 οnfοcusif(value郭强) {value} οnblurif (value) {value郭强}点击时文字消失失去焦点时文字再出现 2.网页按钮的特殊颜色input typebutton nameSubmit1 value郭强 size10 classs02 stylebackground-color:rgb(235,207,22) 3.鼠标移入移出时颜色变化input typesubmit value找吧 nameB1 onMouseOutthis.style.colorblue onMouseOverthis.style.colorred classbutton 4.平面按钮input typesubmit value订阅 styleborder:1px solid :#666666; height:17px; width:25pt; font-size:9pt; BACKGROUND-COLOR: #E8E8FF; color:#666666 namesubmit 5.按钮颜色变化input typetext namenick styleborder:1px solid #666666; font-size:9pt; height:17px; BACKGROUND-COLOR: #F4F4FF; color:#ff6600 size15 maxlength16 6.平面输入框input typetext nameT1 size20 styleborder-style: solid; border-width: 1 7.使窗口变成指定的大小scriptwindow.resizeTo(300,283);/script 8.使文字上下滚动marquee directionup scrollamount1 scrolldelay100 οnmοuseοverthis.stop() οnmοuseοutthis.start() height60!-- head_scrolltext --trtd共和国/table !-- end head_scrolltext --/marquee 9.状态栏显示该页状态base οnmοuseοverwindow.status网站建设 http://www.webmake.cn/ ;return true 10.可以点击文字实现radio选项的选定brnbsp;nbsp;nbsp;nbsp;input typeradio nameregtype valueA03 idA03label forA03 情侣 : 一次注册两个帐户/label br 11.可以在文字域的font写onclick事件 12.打印/a打印网页a hrefjavascript:window.print () 13.线型输入框input typetext namekey size12 value关键字 onFocusthis.select() onMouseOverthis.focus() classline 14.显示文档最后修改日期script languagejavascriptfunction hi(str){ document.write(document.lastModified) alert(histr!)}/script 15.可以在鼠标移到文字上时就触发事件htmlheadscript languageLiveScript!-- Hiding function hello() { alert(哈罗!); }/script/headbodya href onMouseOverhello()link/a/body/html 16.可以根据网页上的选项来确定页面颜色HTMLHEAD TITLEbackground.html/TITLE/HEADSCRIPT!-- function bgChange(selObj) { newColor selObj.options[selObj.selectedIndex].text; document.bgColor newColor; selObj.selectedIndex -1; } //--/SCRIPTBODY STYLEfont-family:ArialBChanging Background Colors/BBR FORM SELECT SIZE8 onChangebgChange(this); OPTIONRed OPTIONOrange OPTIONYellow OPTIONGreen OPTIONBlue OPTIONIndigo OPTIONViolet OPTIONWhite OPTIONpink /SELECT /FORM/BODY/HTML 17.将按钮的特征改变style typetext/css!--.style1 { font-size: 12px; background: #CCCCFF; border-width: thin thin thin thin; border-color: #CCCCFF #CCCCCC #CCCCCC #CCCCFF}.style2 { font-size: 12px; font-weight: bold; background: #CCFFCC; border-width: thin medium medium thin; border-color: #CCFF99 #999999 #999999 #CCFF99}--/style 本例按钮的代码如下input typesubmit nameSubmit value提 交 οnmοuseοverthis.classNamestyle2 οnmοuseοutthis.classNamestyle1 classstyle1 18.改变按钮的图片.style typetext/css!--.style3 { font-size: 12px; background: url(image/buttonbg1.gif); border: 0px; width: 60px; height: 22px}.style4 { font-size: 12px; font-weight: bold; background: url(image/buttonbg2.gif); border: 0px 0; width: 60px; height: 22px}--/style 本例的按钮代码如下 input typesubmit nameSubmit2 value提 交 οnmοuseοverthis.classNamestyle4 οnmοuseοutthis.classNamestyle3 classstyle3 19.打印页面div aligncentera classcontent hrefjavascript:doPrint();打印本稿/a/div 20.可以直接写html语言document.write(); 21.改变下拉框的颜色select nameclassid onChangechangelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value) size1 stylecolor:#008080;font-size: 9pt 22.转至目标URLwindow.locationhttp://guoguo 23.传递该object的formUpdateSN(guoqiang99267,this.form) function UpdateSN(strValue,strForm){ strForm.SignInName.value strValue; return false;} 24.文字标签label forAltName4input nameAltName typeRADIO tabindex931 idAltName4 guoqiang99859/label 25.layer2为组件的ID可以控制组件是否可见document.all.item(Layer2).style.display block;document.all.item(Layer2).style.display none;// 26.将页面加入favorite中script languagejavascript !-- function Addme(){ url http://your.site.address; //你自己的主页地址 title Your Site Name; //你自己的主页名称 window.external.AddFavorite(url,title); -- /script// 27.过10秒自动关闭页面 script languageJavaScript function closeit() {setTimeout(self.close()10000)} /script 28.可以比较字符的大小charpost.charAt(i);if(!(0charchar9)) 29.将字符转化为数字month parseInt(char) 30.点击value非空的选项时转向指定连接 select οnchangeif(this.value!)window.open(this.value) classtextinput option selected主办单位/option option-----------------/option option valuehttp://www.bjd.com.cn/北京日报/option option valuehttp://www.ben.com.cn/北京晚报/option/select 31.改变背景颜色td width* classdp bgColor#FAFBFC οnmοuseοverthis.bgColor#FFFFFF; οnmοuseοutthis.bgColor#FAFBFC; 32.改变文字输入框的背景颜色style.input2 {background-image: url(../images/inputbg.gif); font-size: 12px; background-color: #D0DABB;border-top-width:1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}/styleinput namecontent typetext size47 classinput2 maxlength50 33.改变水平线的特征hr size0 noshade color#C0C0C0 34.传递参数的方式a hrefvote.asp?CurPage8id34888/a 35.页内跳转a href#11/aa href#22/aa href#33/aa href#44/aa href#55/aa href#66/aa href#77/aa name1dfdf/aa name2dfdf/a// 36.两个按键一起按下if(event.ctrlKey window.event.keyCode13)// 37.刷新页面javascript:this.location.reload()// 38.将网页的按钮使能SCRIPT LANGUAGEJavaScriptfunction haha(){ for(var i0;idocument.form1.elements.length;i) { if(document.form1.elements[i].name.indexOf(bb)!-1) document.form1.elements[i].disabled!document.form1.elements[i].disabled; }}/SCRIPTBODYform nameform1INPUT TYPEbutton NAMEaa valuecindy οnclickhaha()INPUT TYPEbutton NAMEbb valueguoguoINPUT TYPEbutton NAMEbb valueguoguo 39.文字移动marquee scrollamount3 οnmοuseοverthis.stop(); οnmοuseοutthis.start(); 40.双击网页自动跑SCRIPT LANGUAGEJavaScriptvar currentpos,timer; function initialize() { timersetInterval(scrollwindow(),1);} function sc(){ clearInterval(timer);}function scrollwindow() { currentposdocument.body.scrollTop; window.scroll(0,currentpos); if (currentpos ! document.body.scrollTop) sc();} document.οnmοusedοwnscdocument.οndblclickinitialize/SCRIPT// 41.后退INPUT TYPEbutton οnclickwindow.history.back() valueback 42.前进INPUT TYPEbutton οnclickwindow.history.forward() valueforward 43.刷新INPUT TYPEbutton οnclickdocument.location.reload() valuereload 44.转向指定网页document.locationhttp://ww或者document.location.assign(http://guoguo.com) 45.在网页上显示实时时间SCRIPT LANGUAGEJavaScriptvar clock_id;window.οnlοadfunction(){ clock_idsetInterval(document.form1.txtclock.value(new Date);,1000)}/SCRIPT// 46.可以下载文件 document.location.href目标文件// 47.连接数据库import java.sql.*;String myDBDriversun.jdbc.odbc.JdbcOdbcDriver;Class.forName(myDBDriver);Connection connDriverManager.getConnection(jdbc:odbc:firm,username,password);Statement stmtconn.createStatement();ResultSet rsstmt.executeQuery(sql);rs.getString(column1);// 48.可以直接在页面“div”内写下所需内容INPUT TYPEbutton οnclicka1.innerHTMLfont colorred*/fontdiv ida1/div// 49.可以改变页面上的连接的格式使其为双线styleA: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 styleA: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.新建framea hrefjavascript:newframe(http://www.163.net/help/a_little/index.html,http://www.163.net/help/a_little /a_13.html)img alt帮助 border0 srchttp://bjpic.163.net/images/mail/button-help.gif/a 51.向文件中写内容% page importjava.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; charSetgb2312 %% page import java.util.* %% page import java.lang.* %% page import javax.servlet.* %% page import javax.servlet.jsp.* %% page import javax.servlet.http.* %% page importjava.io.* %eryrytry% int count0; 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 namePassword size10 typepassword styleborder-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 width65 aligncenter bgcolor#E0E0E0 οnmοuseοverthis.classNamemouseoverbt; οnmοuseοutthis.classNamemouseout;a hreftm.asp?classid76font color#000000录音笔/font/a/tdstyle.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.οnkeydοwnfunction(){if(event.ctrlKeyevent.keyCode81){alert(1)}}// 56.以下是一个完整的显示hint的代码其思想是当鼠标停留是将div中的内容显示在鼠标出当鼠标移出后在将该div隐 藏掉--------------------------------------------------------------------------------------------------------- ------------!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//ENHTMLstyle#hint{ width:198px; border:1px solid #000000; background:#99ff33; position:absolute; z-index:9; padding:6px; line-height:17px; text-align:left; top: 1520px;}/styleSCRIPT LANGUAGEJavaScript!--function showme(){ var oSonwindow.document.getElementById(hint); if (oSonnull) return; with (oSon) { innerTextguoguo.value; style.displayblock; style.pixelLeftwindow.event.clientXwindow.document.body.scrollLeft6; style.pixelTopwindow.event.clientYwindow.document.body.scrollTop9; }}function hidme(){ var oSonwindow.document.getElementById(hint); if (oSonnull) return; oSon.style.displaynone;}//--/SCRIPTBODYtext idguoguo valuegaa href# οnmοuseοvershowme() οnmοuseοuthidme() οnmοusemοveshowme() sonhintdfdfd/adiv idhint styledisplay:none/div/BODY/HTML--------------------------------------------------------------------------------------------------------- ------------ 57.弹出窗口方法一body οnlοadopenwen() 浏览器读页面时弹出窗口 方法二body οnunlοadopenwen() 浏览器离开页面时弹出窗口 方法三用一个连接调用a href# οnclickopenwin()打开一个窗口/a 注意使用的#是虚连接。 方法四用一个按钮调用input typebutton οnclickopenwin() value打开窗口 何时装载script 58.动态改变字体的大小function doZoom(size){ document.getElementById(zoom).style.fontSizesizepx} function aa(){ var newWinwindow.open(url); newWin.document.form1.text1.valuevalue1;}改变弹出窗口上域的属性opener.document.form2.text2.valuevalue2;改变父窗口的域的值 59.判断是何种浏览器var name navigator.appName;if (name Microsoft Internet Explorer) alert(IE);else if (name Netscape) alert(NS);// 60.vbsscript确定框script languageVBScript!--MsgBox 确定删除吗, 4 //--/script// 61.复制内容到剪切板function JM_cc(bb){ var obeval(document.form1.bb); ob.select(); jsob.createTextRange(); js.execCommand(Copy);}// 62.java中建立数据库连接取数据public void init(){ String urljdbc:odbc:javadata; try { Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); Connection conDriverManager.getConnection(url,sa,);//mssql database user SA and password DatabaseMetaData dmacon.getMetaData(); System.out.println(Connect todma.getURL()); System.out.println(;Driver dma.getDriverName()); System.out.println(;Version dma.getDriverVersion()); System.out.println(); Statement stmtcon.createStatement(); ResultSet rsstmt.executeQuery(select * from company.dbo.TB_NAME where number1);//Sql rs.next(); String dispresultrs.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()); exex.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,help0); if (color ! null) { document.compose.bgcolor.value color; }}// 70.截取小数点后两位var a3454545.4454545;alert(a.toFixed(2));// 71.禁止选择页面上的文字来拷贝scriptfunction noEffect() { with (event) { returnValue false; cancelBubble true; } return;}/scriptbody onselectstartnoEffect() οncοntextmenunoEffect()// 72.屏蔽右键菜单οncοntextmenuevent.returnValue false// 73.事件禁止起泡event.cancelBubble true// 74.禁止在输入框打开输入法input styleime-mode: disabled// 75.屏蔽汉字和空格input nametxtinput typesubmit onClickalert(!/[^ -}]|/s/.test(txt.value))// 76.用javascript判断文件是否存在function Exists(filespec){ if (filespec) { var fso; fso new ActiveXObject(Scripting.FileSystemObject); alert(fso.FileExists(filespec)); }}选择图片 input typefile namef1pinput typesubmit onClickExists(f1.value)// 77.获得当前的文本框选中的文字input οnmοuseupalert(document.selection.createRange().text) value123// 78.跳转至目标页面同时不可返回a hrefjavascript:location.replace(http://www.sohu.com/)sohu.com/a// 79.获得当前的行是表格的第几行scriptfunction getrow(obj){ if(event.srcElement.tagNameTD){ curRowevent.srcElement.parentElement; alert(这是第(curRow.rowIndex1)行); }}/script table border1 width100% οnclickgetrow(this) tr td width20% /td td width20% /td td width20% /td td width20% /td td width20% /td /tr tr td width20% /td td width20% /td td width20% /td td width20% /td td width20% /td /tr/table// 80.删除表格某行xx表示某行下标从0开始计算document.all.myTable.deleteRow(xx)// 81.动态的向表格中添加行table idt1 border1/tablescript languageJavaScriptfunction add(){ t1.insertRow().insertCell().innerHTML input nametestt1.rows.length;}// 82.event.x,event.clientX,event.offsetX区别x:设置或者是得到鼠标相对于目标事件的父元素的外边界在x坐标上的位置。 clientX:相对于客户区域的x坐标位置不 包括滚动条就是正文区域。 offsetx设置或者是得到鼠标相对于目标事件的父元素的内边界在x坐标上的位置。 screenX:相对于用户屏幕。 83.显示是鼠标按钮的哪个body onMouseDownalert(event.button)点Mouse看看// 84.打开C盘form actionfile:///c|/input typesubmit valuec:/ drive/form// 85.当前屏幕的分辨率screen.width、screen.height// 86.设置表格中的内容tbl.rows[0].cells[1].innerTextdocument.form.text1.value;// 87.本地快捷键pa hreffile:///::{208D2C60-3AEA-1069-A2D7-08002B30309D} target_blank网上邻居/a/ppa hreffile:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}/d:/web target_blank我的电脑/a/ppa hreffile:///::{450D8FBA-AD25-11D0-98A8-0800361B1103} target_blank我的文档/a/ppa hreffile:///::{645FF040-5081-101B-9F08-00AA002F954E} target_blank回收站/a/ppa hreffile:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}/::{21EC2020-3AEA-1069-A2DD-08002B30309D} target_blank控制面板/a/ppa hreffile:///::{7007ACC7-3202-11D1-AAD2-00805FC1270E}拨号网络/a(windows 2000)/p 88.IE菜单button οnclickmin.Click()font facewebdings0/font/button//改变按钮上的图片input typebutton οnclickdocument.execCommand(CreateLink,true,true) //创建新连接input typebutton οnclickdocument.execCommand(print,true,true) //打印input typebutton οnclickdocument.execCommand(saveas,true,网站制作.htm)//另存为htminput typebutton οnclickdocument.execCommand(saveas,true,网站制作.txt)//另存为txtdocument.execCommand(SaveAs)//保存为document.execCommand(undo)//撤销上一次操作 89.web对话框SCRIPTvar contentsstylebody,td{font:menu}img{cursor:hand}/style;contentstitle你要关闭我吗/title;contentsbody bgcolormenu;contentstable width100% height100% border0;contentstrtd aligncenter;contents你要关闭我吗br;contentsimg srcdark.gif οnclickself.close() alt...关闭;contentsimg srcjet.gif οnclickself.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 οnclickt1.rows[x].cells[y].innerTextguoguo/button// 91.向新打开的网页上写内容newwinwindow.open(about:blank,,top10);newwin.document.write();// 93.返回javascript:history.go(-2);// 94.将页面上选中的内容复制到剪贴板abcdefginput typebutton οnclickwindow.clipboardData.setData(text,document.selection.createRange().text); value复制页面选中 的字符//95.将页面上选中的内容复制到剪贴板INPUT TYPEtext NAMEkjhkjhkhkjINPUT TYPEbutton οnclickdocument.execCommand(Copy, false, null); 96.鼠标移到下拉框时自动全部打开select οnmοuseοverjavascript:this.sizethis.length οnmοuseοutjavascript:this.size1/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.在页面上画柱状图STYLEtd{font-size:12px}body{font-size:12px}v/:*{behavior:url(#default#VML);} //这里声明了v作为VML公用变量/STYLESCRIPT LANGUAGEJavaScriptmathstr12;document.write (v:rect fillcolorred stylewidth:20;color:navy;height:5000/(1000/mathstr)brnbsp;%mathstrbr4人v:Extrusion backdepth15pt ontrue//v:rect)/SCRIPTv:rect fillcolorred stylewidth:20;color:navy;height:200br%12br4人v:Extrusion backdepth15pt ontrue//v:rectv:rect fillcoloryellow stylewidth:20;color:navy;height:100br%12br4人v:Extrusion backdepth15pt ontrue//v:rect// 101.饼图stylev/:* { behavior: url(#default#VML) }o/:* { behavior: url(#default#VML) }.shape { behavior: url(#default#VML) }/stylescript languagejavascriptfunction show(pie){pie.strokecolorpie.fillcolor;pie.strokeweight10;div1.innerHTMLfont size2 colorred pie.id /font font size2 pie.title /font;}function hide(pie){pie.strokecolorwhite;pie.strokeweight1;div1.innerHTML;}/script/headbodyv:group stylewidth: 5cm; height: 5cm coordorigin0,0 coordsize250,250v:shape idasp技术 stylewidth:10;height:10;top:10;left:0 title得票数:6 比例:40.00% οnmοuseοverjavascript:show(this); οnmοuseοutjavascript:hide(this); hrefhttp://www.cnADO.com CoordSize10,10 strokecolorwhite fillcolor#ffff33v:path vm 300,200 ae 300,200,200,150,0,9437184 xe//v:shapev:shape idphp stylewidth:10;height:10;top:10;left:0 title得票数:1 比例:6.67% οnmοuseοverjavascript:show(this); οnmοuseοutjavascript:hide(this); hrefhttp://www.cnADO.com CoordSize10,10 strokecolorwhite fillcolor#ff9933v:path vm 300,200 ae 300,200,200,150,9437184,1572864 xe//v:shapev:shape idjsp stylewidth:10;height:10;top:10;left:0 title得票数:2 比例:13.33% οnmοuseοverjavascript:show(this); οnmοuseοutjavascript:hide(this); hrefhttp://www.cnADO.com CoordSize10,10 strokecolorwhite fillcolor#3399ffv:path vm 300,200 ae 300,200,200,150,11010048,3145728 xe//v:shapev:shape idc#写的.netWEB程序 stylewidth:10;height:10;top:10;left:0 title得票数:3 比例:20.00% οnmοuseοverjavascript:show(this); οnmοuseοutjavascript:hide(this); hrefhttp://www.cnADO.com CoordSize10,10 strokecolorwhite fillcolor#99ff33v:path vm 300,200 ae 300,200,200,150,14155776,4718592 xe//v:shapev:shape idvb.net写的.netWEB程序 stylewidth:10;height:10;top:10;left:0 title得票数:2 比例:13.33% οnmοuseοverjavascript:show(this); οnmοuseοutjavascript:hide(this); hrefhttp://www.cnADO.com CoordSize10,10 strokecolorwhite fillcolor#ff6600v:path vm 300,200 ae 300,200,200,150,18874368,3145728 xe//v:shapev:shape idxml技术 stylewidth:10;height:10;top:10;left:0 title得票数:1 比例:6.67% οnmοuseοverjavascript:show(this); οnmοuseοutjavascript:hide(this); hrefhttp://www.cnADO.com CoordSize10,10 strokecolorwhite fillcolor#ff99ffv:path vm 300,200 ae 300,200,200,150,22020096,1572864 xe//v:shape/v:group v:group stylewidth: 6cm; height: 6cm coordorigin0,0 coordsize250,250v:rect styleheight:10;width:15;top:0;left:10 fillcolor#ffff33/v:rect styleheight:28;width:100;top:0;left:30 strokedfalsev:textbox stylefontsize:2asp技术/v:textbox//v:rectv:rect styleheight:10;width:15;top:30;left:10 fillcolor#ff9933/v:rect styleheight:28;width:100;top:30;left:30 strokedfalsev:textbox stylefontsize:2php/v:textbox//v:rectv:rect styleheight:10;width:15;top:60;left:10 fillcolor#3399ff/v:rect styleheight:28;width:100;top:60;left:30 strokedfalsev:textbox stylefontsize:2jsp/v:textbox//v:rectv:rect styleheight:10;width:15;top:90;left:10 fillcolor#99ff33/v:rect styleheight:28;width:100;top:90;left:30 strokedfalsev:textbox stylefontsize:2c#写的.netWEB程序/v:textbox//v:rectv:rect styleheight:10;width:15;top:120;left:10 fillcolor#ff6600/v:rect styleheight:28;width:100;top:120;left:30 strokedfalsev:textbox stylefontsize:2vb.net 写的.netWEB程序/v:textbox//v:rectv:rect styleheight:10;width:15;top:150;left:10 fillcolor#ff99ff/v:rect styleheight:28;width:100;top:150;left:30 strokedfalsev:textbox stylefontsize:2xml技术 /v:textbox//v:rect/v:group div styleposition: absolute; left: 10; top: 10; width: 760; height:16 table border1 cellpadding2 cellspacing2 cellpadding0 cellspacing0 styleborder-collapse: collapse bordercolor#CCCCCC width100% IDTable1 tr td width100% iddiv1 /td /tr /table/div// 102.是一个特殊的容器想装个网页都行buttoniframe srchttp://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}/styleinput classOutnone οnmοuseοverthis.classNameOvernone // 107.页面翻转html dirrtl/html// 108.滚屏parent.scroll(x,y);//body οnlοads0 onDblClickssetInterval(scrollBy(0, 1),10) onClickclearInterval(s)// 109.改变状态栏self.status ;// 110.改变窗口大小window.resizeTo(200,300);// 111.改变鼠标样式styleBODY{CURSOR: url(mouse.ani);SCROLLBAR-BASE-COLOR: #506AA8; SCROLLBAR-ARROW-COLOR: #14213F;}// 112.背景透明input typebutton valueButton stylebackground-color: transparent; border: 0;// 113.鼠标为等待形状input typebutton οnclickthis.style.cursorwait// 114.调用父窗口的函数opener.fucntion1();// 115.body的内部html代码input typebutton οnclickalert(code.document.body.innerHTML) value查看// 116.框架中调用父窗口的函数INPUT TYPEbutton οnclickparent.test(); value调用parent窗口的函数// 117.交换节点table width200 height200 bordertrtd idc1CELL_1/td/trtrtd idc2CELL_2/td/tr/tablebrinput typebutton valueswap row οnclickc1.swapNode(c2)// 118.删除节点table width200 height200 bordertr idtralltd idc1CELL_1/td/trtrtd idc2CELL_2/td/tr/tablebrinput typebutton valueswap row οnclicktrall.removeNode(c2)// 119.添加节点addNode()// 120.获得事件的父与子标签event.srcElement.children[0]和event.srcElement.parentElement // 121.集中为按钮改变颜色stylebutton{benc:expression(this.onfocus function(){this.style.backgroundColor#E5F0FF;})}/stylebuttonNew/button// 122.判断是左键还是右键被按下body οnmοusedοwnif(event.button1)alert(左键);if(event.button2)alert(右键)// 123.获得操作系统的名称和浏览器的名称document.write(navigator.userAgent)// 124.alt/ctrl/shift键按下event.altKey //按下alt键event.ctrlKey //按下ctrl键event.shiftKey //按下shift键 125.将当前位置定位为C盘。{window.locationc:}// 126.返回输入框的类型scriptalert(event.srcElement.type);///script 127.模拟控件的单击事件INPUT TYPEhidden nameguoguo οnclickhaha()SCRIPT LANGUAGEJavaScript!-- 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.keyCode13) event.keyCode9; //将 131.滚动条滚动button οnclicktext1.scrollToptext1.scrollHeightScroll/buttonbrtextarea idtext1 cols50 rows10111111111111111/textarea// 132.判断是什么对象if(typeof(unknown)function)return true;if(typeof(unknown)!object)return false;// 133.取消文本框自动完成功能input typetext autocompleteoff // 134.让下拉框自动下拉select οnmοuseοverjavascript:this.sizethis.length οnmοuseοutjavascript:this.size1option value1/optionoption value2/optionoption value3/option/select // 135.读取XML文件var childrenobjmyselect//document.all.myselect; var oXMLDoc new ActiveXObject(MSXML); oXMLDoc.url mymsg.xml; var oRootoXMLDoc.root; if(oRoot.children ! null) { for(var i0;ioRoot.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 version1.0 encodinggb2312 ?childrenlistaachild value3301杭州地区/child child value3303温州地区/child /aaaachild value3310台州地区/child child value3311丽水地区/child/aa/childrenlist// 136.点击图片图片停止a hrefjavascript:img srchttp://www.51js.com/images/51js/red_forum.gif border0/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(); tDatedDate?alert(早于):alert(晚于);// 139.弹出鼠标所在处的链结地址 body οnmοuseοverif (event.srcElement.tagNameA)alert(event.srcElement.href)a hrefhttp://51js.com/viewthread.php?tid13589 dddd/ainput// 140.注意不能通过与 undefined 做比较来测试一个变量是否存在虽然可以检查它的类型是否为“undefined”。在以 下的代码范例中假设程序员想测试是否已经声明变量 x // 这种方法不起作用if (x undefined) // 作某些操作// 这个方法同样不起作用- 必须检查 // 字符串 undefinedif (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 a23.2;alert(a%11)// 144.新建日期型变量var a new Date(2000, 1, 1);alert(a.toLocaleDateString()); 145.给类定义新的方法function trim_1(){ return this.replace(/(^/s*)|(/s*$)/g, );}String.prototype.trimtrim_1;alert(cindy.trim()); 146.定义一个将日期类型转化为字符串的方法function guoguo_date(){ var tmp1,tmp2; tmp1 this.getMonth()1; if(tmp1.length2) tmp10tmp1; tmp2 this.getDate(); if(tmp2.length2) tmp20tmp2; return this.getYear()-tmp1-tmp2;}Date.prototype.toLiteStringguoguo_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.toStringaa;}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 (i0; icoll.length; i) ...}// 151.实现打印预览及打印OBJECT classidCLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height0 idwb namewb width0/OBJECT input typebutton value打印预览 οnclickwb.execwb(7,1)input typebutton onClickdocument.all.wb.ExecWB(6,1) value打印// 152.不通过form直接通过名字引用对象INPUT TYPEtext NAMEgg valueaaaaaSCRIPT LANGUAGEJavaScript!--alert(document.all.gg.value)//--/SCRIPT// 153.使鼠标滚轮失效function document.onmousewheel(){ return false;}// 154.创建弹出窗口SCRIPT LANGUAGEJScript var oPopup window.createPopup(); var oPopupBody oPopup.document.body; oPopupBody.innerHTML Display some BHTML/B here.; oPopup.show(100, 100, 200, 50, document.body);/SCRIPT// 155.取得鼠标所在处的对象var obj document.elementFromPoint(event.x,event.y);// 156.获得左边的对象INPUT TYPEtext NAMEggINPUT TYPEtext NAMEbb οnclickthis.previousSibling.valueguoguo// 157.定位鼠标document.all.hint_layer.style.left event.xdocument.body.scrollLeft10;document.all.hint_layer.style.top event.ydocument.body.scrollTop10;// 158.向下拉框指定位置添加项目var op document.createElement(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 awindow.open(,,);// 160.动态创建一个标签newElem document.createElement(DIV);newElem.id hint_layer;document.body.appendChild(newElem);document.all.hint_layer.innerTextguoguo;// 161.标题栏document.title// 162.背景图片body styleBACKGROUND-ATTACHMENT: fixed backgroundimg/bgfix.gif /body//背景图片不动 STYLE TYPEtext/css!--BODY {background-image:img/bgchild.jpg;background-position: center;background-repeat: no-repeat;background-attachment: fixed;}--/STYLE//背景图片居中 163.设置透明效果document.form.xxx.filters.alpha.opacity0100// 164.定义方法var dragapprovedfalse;document.οnmοuseupnew Function(dragapproved false);// 165.将数字转化为人民币大写形式function convertCurrency(currencyDigits) {// Constants: var MAXIMUM_NUMBER 99999999999.99; // Predefine the radix characters and currency symbols for output: var CN_ZERO 零; var CN_ONE 壹; var CN_TWO 贰; var CN_THREE 叁; var CN_FOUR 肆; var CN_FIVE 伍; var CN_SIX 陆; var CN_SEVEN 柒; var CN_EIGHT 捌; var CN_NINE 玖; var CN_TEN 拾; var CN_HUNDRED 佰; var CN_THOUSAND 仟; var CN_TEN_THOUSAND 万; var CN_HUNDRED_MILLION 亿; var CN_SYMBOL 人民币; var CN_DOLLAR 元; var CN_TEN_CENT 角; var CN_CENT 分; var CN_INTEGER 整; // Variables: var integral; // Represent integral part of digit number. var decimal; // Represent decimal part of digit number. var outputCharacters; // The output result. var parts; var digits, radices, bigRadices, decimals; var zeroCount; var i, p, d; var quotient, modulus; // Validate input string: currencyDigits currencyDigits.toString(); if (currencyDigits ) { alert(Empty input!); return ; } if (currencyDigits.match(/[^,./d]/) ! null) { alert(Invalid characters in the input string!); return ; } if ((currencyDigits).match(/^((/d{1,3}(,/d{3})*(.((/d{3},)*/d{1,3}))?)|(/d(./d)?))$/) null) { alert(Illegal format of digit number!); return ; } // Normalize the format of input digits: currencyDigits currencyDigits.replace(/,/g, ); // Remove comma delimiters. currencyDigits currencyDigits.replace(/^0/, ); // Trim zeros at the beginning. // Assert the number is not greater than the maximum number. if (Number(currencyDigits) MAXIMUM_NUMBER) { alert(Too large a number to convert!); return ; } // Process the coversion from currency digits to characters: // Separate integral and decimal parts before processing coversion: parts currencyDigits.split(.); if (parts.length 1) { integral parts[0]; decimal parts[1]; // Cut down redundant decimal digits that are after the second. decimal decimal.substr(0, 2); } else { integral parts[0]; decimal ; } // Prepare the characters corresponding to the digits: digits new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE); radices new Array(, CN_TEN, CN_HUNDRED, CN_THOUSAND); bigRadices new Array(, CN_TEN_THOUSAND, CN_HUNDRED_MILLION); decimals new Array(CN_TEN_CENT, CN_CENT); // Start processing: outputCharacters ; // Process integral part if it is larger than 0: if (Number(integral) 0) { zeroCount 0; for (i 0; i integral.length; i) { p integral.length - i - 1; d integral.substr(i, 1); quotient p / 4; modulus p % 4; if (d 0) { zeroCount; } else { if (zeroCount 0) { outputCharacters digits[0]; } zeroCount 0; outputCharacters digits[Number(d)] radices[modulus]; } if (modulus 0 zeroCount 4) { outputCharacters bigRadices[quotient]; } } outputCharacters CN_DOLLAR; } // Process decimal part if there is: if (decimal ! ) { for (i 0; i decimal.length; i) { d decimal.substr(i, 1); if (d ! 0) { outputCharacters digits[Number(d)] decimals[i]; } } } // Confirm and return the final output string: if (outputCharacters ) { outputCharacters CN_ZERO CN_DOLLAR; } if (decimal ) { outputCharacters CN_INTEGER; } outputCharacters CN_SYMBOL outputCharacters; return outputCharacters;}// 166.xml数据岛绑定表格htmlbodyxml idabc srctest.xml/xmltable border1 datasrc#abctheadtd接收人/tdtd发送人/tdtd主题/tdtd内容/td/theadtfoottrth表格的结束/th/tr/tfoottrtddiv datafldto/div/tdtddiv datafldfrom/div/tdtddiv datafldsubject/div/tdtddiv datafldcontent/div/td/tr/table/body/html //cd_catalog.xml?xml version1.0 encodingISO-8859-1 ? !-- Edited with XML Spy v4.2 -- CATALOG CD TITLEEmpire Burlesque/TITLE ARTISTBob Dylan/ARTIST COUNTRYUSA/COUNTRY COMPANYColumbia/COMPANY PRICE10.90/PRICE YEAR1985/YEAR /CD CD TITLEHide your heart/TITLE ARTISTBonnie Tyler/ARTIST COUNTRYUK/COUNTRY COMPANYCBS Records/COMPANY PRICE9.90/PRICE YEAR1988/YEAR /CD CD TITLEGreatest Hits/TITLE ARTISTDolly Parton/ARTIST COUNTRYUSA/COUNTRY COMPANYRCA/COMPANY PRICE9.90/PRICE YEAR1982/YEAR /CD CD TITLEStill got the blues/TITLE ARTISTGary Moore/ARTIST COUNTRYUK/COUNTRY COMPANYVirgin records/COMPANY PRICE10.20/PRICE YEAR1990/YEAR /CD/CATALOG// 167.以下组合可以正确显示汉字xml保存编码 xml页面指定编码ANSI gbk/GBK、gb2312Unicode unicode/UnicodeUTF-8 UTF-8 168.XML操作xml idxmldata src/data/books.xmldiv idguoguo/divscriptvar xxmldata.recordset //取得数据岛中的记录集if(x.absoluteposition x.recordcount) //如果当前的绝对位置在最后一条记录之前{ x.movenext(); //向后移动 x.moveprevious(); //向前移动 x.absoluteposition1; //移动到第一条记录 x.absolutepositionx.recordcount;//移动到最后一条记录注意记录集x.absoluteposition是从1到记录集记录的个 数的 guoguo.innerTextxmldso.recordset(field_name); //从中取出某条记录}/script 169.动态修改CSS的另一种方式this.runtimeStyle.cssText color:#990000;border:1px solid #cccccc;// 170.正则表达式匹配中文字符的正则表达式 [/u4e00-/u9fa5] 匹配双字节字符(包括汉字在内)[^/x00-/xff] 应用计算字符串的长度一个双字节字符长度计2ASCII字符计1 String.prototype.lenfunction(){return this.replace([^/x00-/xff]/g,aa).length;} 匹配空行的正则表达式/n[/s| ]*/r 匹配HTML标记的正则表达式/(.*).*///1|(.*) /// 匹配首尾空格的正则表达式(^/s*)|(/s*$) 应用javascript中没有像vbscript那样的trim函数我们就可以利用这个表达式来实现如下 String.prototype.trim function(){ return this.replace(/(^/s*)|(/s*$)/g, );} 利用正则表达式分解和转换IP地址 下面是利用正则表达式匹配IP地址并将IP地址转换成对应数值的Javascript程序 function IP2V(ip){ re/(/d)/.(/d)/.(/d)/.(/d)/g //匹配IP地址的正则表达式if(re.test(ip)){return RegExp.$1*Math.pow(255,3))RegExp.$2*Math.pow(255,2))RegExp.$3*255RegExp.$4*1}else{ throw new Error(Not a valid IP address!)}} 不过上面的程序如果不用正则表达式而直接用split函数来分解可能更简单程序如下 var ip10.100.20.168ipip.split(.)alert(IP值是(ip[0]*255*255*255ip[1]*255*255ip[2]*255ip[3]*1)) 匹配Email地址的正则表达式/w([-.]/w)*/w([-.]/w)*/./w([-.]/w)* 匹配网址URL的正则表达式http://([/w-]/.)[/w-](/[/w- ./?%]*)? //利用正则表达式去除字串中重复的字符的算法程序 var sabacabefgeeiivar s1s.replace(/(.).*/1/g,$1)var renew RegExp([s1],g)var s2s.replace(re,) alert(s1s2) //结果为abcefgi 思路是使用后向引用取出包括重复的字符再以重复的字符建立第二个表达式取到不重复的字符两者串连。这个方 法对于字符顺序有要求的字符串可能不适用。 //得用正则表达式从URL地址中提取文件名的javascript程序如下结果为page1 shttp://www.9499.net/page1.htmss.replace(/(.*//){0,}([^/.]).*/ig,$2)alert(s) /利用正则表达式限制网页表单里的文本框输入内容 用正则表达式限制只能输入中文οnkeyupvaluevalue.replace(/[^/u4E00-/u9FA5]/g,) onbeforepasteclipboardData.setData(text,clipboardData.getData(text).replace(/[^/u4E00-/u9FA5]/g,) ) 用正则表达式限制只能输入全角字符 οnkeyupvaluevalue.replace(/[^/uFF00-/uFFFF]/g,) onbeforepasteclipboardData.setData(text,clipboardData.getData(text).replace(/[^/uFF00-/uFFFF]/g,) ) 用正则表达式限制只能输入数字οnkeyupvaluevalue.replace(/[^/d]/g,) onbeforepasteclipboardData.setData(text,clipboardData.getData(text).replace(/[^/d]/g,)) 用正则表达式限制只能输入数字和英文οnkeyupvaluevalue.replace(/[/W]/g,) onbeforepasteclipboardData.setData(text,clipboardData.getData(text).replace(/[^/d]/g,)) 171.设置和使用cookieHTMLBODY设置与读取 cookies...BR写入cookie的值input typetext nameggINPUT TYPE BUTTON Value 设置cookie onClick Set()INPUT TYPE BUTTON Value 读取cookie onClick Get()BRINPUT TYPE TEXT NAME Textbox/BODYSCRIPT LANGUAGEJavaScriptfunction Set(){var Then new Date() Then.setTime(Then.getTime() 60*1000 ) //60秒document.cookie Cookie1gg.value;expires Then.toGMTString() } function Get(){ var cookieString new String(document.cookie) var cookieHeader Cookie1 var beginPosition cookieString.indexOf(cookieHeader) if (beginPosition ! -1) { document.all.Textbox.value cookieString.substring(beginPosition cookieHeader.length) } else document.all.Textbox.value Cookie 未找到! }/SCRIPT /HTML// 172.取月的最后一天function getLastDay(year,month){ //取年 var new_year year; //取到下一个月的第一天,注意这里传入的month是从112 var new_month month; //如果当前是12月则转至下一年 if(month12) { new_month -12; new_year; } var new_date new Date(new_year,new_month,1); return (new Date(new_date.getTime()-1000*60*60*24)).getDate();}// 173.判断当前的焦点是组中的哪一个for(var i0;i3;i) if(event.srcElementbb[i]) break;// 174.实现类package com.baosight.view.utils;import javax.servlet.jsp.tagext.TagSupport;import javax.servlet.http.HttpSession;public class Mytag extends TagSupport { public int doStartTag() throws javax.servlet.jsp.JspException { boolean canAccess false; HttpSession session pageContext.getSession(); if (canAccess) { return EVAL_BODY_INCLUDE; } else { return this.SKIP_BODY; } }} 175.在web.xml中添加定义 taglib taglib-uriguoguo/taglib-uri taglib-location/WEB-INF/abc.tld/taglib-location /taglib 176.标签库中定义abc.tld?xml version1.0 encodingUTF-8?!DOCTYPE taglib PUBLIC -//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtdtaglib tlibversion1.0/tlibversion jspversion1.1/jspversion shortnamehr/shortname uriguoguo/uri infoExtra 3 Tag Library/info tag namemytag/name tagclasscom.baosight.view.utils.Mytag/tagclass attribute nameid2/name requiredtrue/required rtexprvaluetrue/rtexprvalue /attribute /tag/taglib 177.在使用自定义标签的页面中加入自己定义的标签% taglib uriguoguo prefixguoguo %//自己定义标签 178.显示带边框的集fieldset styleborder:1px gray solid;width:100px legend查询条件/legenddfdfdf/fieldset// 179.【文件(F)】菜单中的命令的实现 1、〖打开〗命令的实现[格式]:document.execCommand(open)[说明]这跟VB等编程设计中的webbrowser控件中的命令有些相似大家也可依此琢磨琢磨。[举例]在body/body之间加入a href### οnclickdocument.execCommand(open)打开/a 2、〖使用 记事本 编辑〗命令的实现[格式]:location.replace(view-source:location)[说明]打开记事本在记事本中显示该网页的源代码。[举例]在body/body之间加入a href### οnclicklocation.replace(view-source:location)使用 记事本编辑/a 3、〖另存为〗命令的实现[格式]:document.execCommand(saveAs)[说明]将该网页保存到本地盘的其它目录[举例]在body/body之间加入a href### οnclickdocument.execCommand(saveAs)另存为/a 4、〖打印〗命令的实现[格式]:document.execCommand(print)[说明]当然你必须装了打印机[举例]在body/body之间加入a href### οnclickdocument.execCommand(print)打印/a 5、〖关闭〗命令的实现[格式]:window.close();return false[说明]将关闭本窗口。[举例]在body/body之间加入a href### οnclickwindow.close();return false)关闭本窗口/a 180.【编辑(E)】菜单中的命令的实现 〖全选〗命令的实现[格式]:document.execCommand(selectAll)[说明]将选种网页中的全部内容[举例]在body/body之间加入a href### οnclickdocument.execCommand(selectAll)全选/a 181.【查看(V)】菜单中的命令的实现 1、〖刷新〗命令的实现[格式]:location.reload() 或 history.go(0)[说明]浏览器重新打开本页。[举例]在body/body之间加入a href### οnclicklocation.reload()刷新/a或加入:a href### οnclickhistory.go(0)刷新/a 2、〖源文件〗命令的实现[格式]:location.replace(view-source:location)[说明]查看该网页的源代码。[举例]在body/body之间加入a href### οnclicklocation.replace(view-source:location)查看源文件/a 3、〖全屏显示〗命令的实现[格式]:window.open(document.location, url, fullscreen)[说明]全屏显示本页。[举例]在body/body之间加入a href### οnclickwindow.open(document.location,url,fullscreen)全屏显示/a 182.【收藏(A)】菜单中的命令的实现 1、〖添加到收藏夹〗命令的实现[格式]:window.external.AddFavorite(url, “网站名”)[说明]将本页添加到收藏夹。[举例]在body/body之间加入a hrefjavascript:window.external.AddFavorite(http://oh.jilinfarm.com, 胡明新的个人主页)添加到收 藏夹/a 2、〖整理收藏夹〗命令的实现[格式]:window.external.showBrowserUI(OrganizeFavorites,null)[说明]打开整理收藏夹对话框。[举例]在body/body之间加入a href### οnclickwindow.external.showBrowserUI(OrganizeFavorites,null)整理收藏夹/a 183.【工具(T)】菜单中的命令的实现 〖internet选项〗命令的实现[格式]:window.external.showBrowserUI(PrivacySettings,null)[说明]打开internet选项对话框。[举例]在body/body之间加入a href### οnclickwindow.external.showBrowserUI(PrivacySettings,null)internet选项/a 184.【工具栏】中的命令的实现 1、〖前进〗命令的实现[格式]history.go(1) 或 history.forward()[说明]浏览器打开后一个页面。[举例]在body/body之间加入a href### οnclickhistory.go(1)前进/a或加入:a href### οnclickhistory.forward()前进/a 2、〖后退〗命令的实现[格式]:history.go(-1) 或 history.back()[说明]浏览器返回上一个已浏览的页面。[举例]在body/body之间加入a href### οnclickhistory.go(-1)后退/a或加入:a href### οnclickhistory.back()后退/a 3、〖刷新〗命令的实现[格式]:document.reload() 或 history.go(0)[说明]浏览器重新打开本页。[举例]在body/body之间加入a href### οnclicklocation.reload()刷新/a或加入:a href### οnclickhistory.go(0)刷新/a 185.其它命令的实现〖定时关闭本窗口〗命令的实现[格式]:settimeout(window.close(),关闭的时间)[说明]将关闭本窗口。[举例]在body/body之间加入a href### οnclicksettimeout(window.close(),3000)3秒关闭本窗口/a 【附】为了方便读者下面将列出所有实例代码你可以把它们放到一个html文件中然后预览效果。a href### οnclickdocument.execCommand(open)打开/abra href### οnclicklocation.replace(view-source:location)使用 记事本编辑/abra href### οnclickdocument.execCommand(saveAs)另存为/abra href### οnclickdocument.execCommand(print)打印/abra href### οnclickwindow.close();return false)关闭本窗口/abra href### οnclickdocument.execCommand(selectAll)全选/abra href### οnclicklocation.reload()刷新/a a href### οnclickhistory.go(0)刷新/abra href### οnclicklocation.replace(view-source:location)查看源文件/abra href### οnclickwindow.open(document.location,url,fullscreen)全屏显示/abra hrefjavascript:window.external.AddFavorite(http://homepage.yesky.com, 天极网页陶吧)添加到收藏 夹/abra href### οnclickwindow.external.showBrowserUI(OrganizeFavorites,null)整理收藏夹/abra href### οnclickwindow.external.showBrowserUI(PrivacySettings,null)internet选项/abra href### οnclickhistory.go(1)前进1/a a href### οnclickhistory.forward()前进2/abra href### οnclickhistory.go(-1)后退1/a a href### οnclickhistory.back()后退2/abra href### οnclicksettimeout(window.close(),3000)3秒关闭本窗口/abr 186.给DHTML中的标签添加一个新的属性可以随意加BODY οnlοadalert(a1.epass)input typetext namea1 epasszhongguo/BODY// 187.xmlhttp技术BODY 此方法是通过XMLHTTP对象从服务器获取XML文档示例如下。 input typebutton value加载XML文档 οnclickgetData(data.xml) script languageJavaScript function getDatal(url){ var xmlhttp new ActiveXObject(Microsoft.XMLHTTP);//创建XMLHTTPRequest对象 xmlhttp.open(GET,url,false,,);//使用HTTP GET初始化HTTP请求 xmlhttp.send();//发送HTTP请求并获取HTTP响应 return xmlhttp.responseXML;//获取XML文档 } /script /BODY// 188.服务器端通过request.getReader()获得传入的字符串 189.在java中使用正则表达式java.util.regex.Pattern p java.util.regex.Pattern.compile(//d|.//d|//d.//d*|(E|//dE|.//dE|//d.//d*E)((//|-)//d|//d)//d*);java.util.regex.Matcher m p.matcher(12.E3);boolean result m.matches();// 190.给下拉框分组SELECTOPTGROUP LABEL碱性金属OPTION锂 (Li)/OPTIONOPTION纳 (Na)/OPTIONOPTION钾 (K)/OPTION/OPTGROUPOPTGROUP LABEL卤素OPTION氟 (F)/OPTIONOPTION氯 (Cl)/OPTIONOPTION溴 (Br)/OPTION/OPTGROUP/SELECT// 191.加注音RUBY基准文本RT注音文本/RUBY// 192.加删除线S此文本将带删除线显示。/S// 193.取frame中的event事件document.frames(workspace).event.keyCode// 194.是弹出方法的定义String.prototype.trimfunction(){ return this.replace(/(^/s*)|(/s*$)/g, );}alert( .trim)// 195.防止网页被包含if (window ! window.top)top.location.href location.href;// 196.让网页一直在frame里面if(windowwindow.top){ document.body.innerHTMLcenterh1请通过正常方式访问本页面/h1/center; //window.close();}// 197.加为首页SCRIPTfunction fnSet(){oHomePage.setHomePage(location.href);event.returnValue false;}/SCRIPTIE:HOMEPAGE IDoHomePage stylebehavior:url(#default#homepage)/// 198.xml数据岛操作HTML HEADTitleHTML中的数据岛中的记录集/Title/HEAD body bkcolor#EEEEEE textblue bgcolor#00FFFF Table aligncenter width100%TRTD aligncenter h5bfont size4 color#FF0000HTML中的XML数据岛记录编辑与添加 /font/b/h5 /TD/TR/Table HR 酒店名称input typetext datasrc#theXMLisland DataFLDNAME size76BR 地址input typetext datasrc#theXMLisland DataFLDAddress size76BR 主页input typetext datasrc#theXMLisland DataFLDHomePage size76BR 电子邮件input typetext datasrc#theXMLisland DataFLDE-Mail size76BR 电话input typetext datasrc#theXMLisland DataFLDTelePhone size76BR 级别input typetext datasrc#theXMLisland DataFLDGrade size76HR input idfirst TYPEbutton value 第一条记录 οnclicktheXMLisland.recordset.moveFirst() input idprev TYPEbutton value上一条记录 οnclicktheXMLisland.recordset.movePrevious() input idnext TYPEbutton value下一条记录 οnclicktheXMLisland.recordset.moveNext() input idlast TYPEbutton value最后一条记录 οnclicktheXMLisland.recordset.moveLast()nbsp; input idAdd TYPEbutton value添加新记录 οnclicktheXMLisland.recordset.addNew() XML IDtheXMLisland HotelList Hotel Name四海大酒店/Name Address海魂路1号/Address HomePagewww.sihaohotel.com.cn/HomePage E-Mailmastersihaohotel.com.cn/E-Mail TelePhone(0989)8888888/TelePhone Grade五星级/Grade /Hotel Hotel Name五湖宾馆/Name Address东平路99号/Address HomePagewww.wuhu.com.cn/HomePage E-Mailwebwuhu.com.cn/E-Mail TelePhone(0979)1111666/TelePhone Grade四星级/Grade /Hotel Hotel Name“大沙漠”宾馆/Name Address留香路168号/Address HomePagewww.dashamohotel.com.cn/HomePage E-Mailmasterdashamohotel.com.cn/E-Mail TelePhone(0989)87878788/TelePhone Grade五星级/Grade /Hotel Hotel Name“画眉鸟”大酒店/Name Address血海飘香路2号/Address HomePagewww.throstlehotel.com.cn/HomePage E-Mailchuliuxiangthrostlehotel.com.cn/E-Mail TelePhone(099)9886666/TelePhone Grade五星级/Grade /Hotel /HotelList /XML /body /HTML //xml数据岛中添加记录 ------------------------------- The following list is a sample of the properties and methods that you use to access nodes in an XML document. Property/ Method Description XMLDocument Returns a reference to the XML Document Object Model (DOM) exposed by the object. documentElement Returns the document root of the XML document. childNodes Returns a node list containing the children of a node (if any). item Accesses individual nodes within the list through an index. Index values are zero-based, so item(0) returns the first child node. text Returns the text content of the node. The following code shows an HTML page containing an XML data island. The data island is contained within the XML element. HTML HEAD TITLEHTML with XML Data Island/TITLE /HEAD BODY PWithin this document is an XML data island./P XML IDresortXML resorts resort code1Adventure Works/resort resortAlpine Ski House/resort /resorts /XML /BODY/HTMLFor an example, you can cut and paste this sample line of code: resortXML.XMLDocument.documentElement.childNodes.item(1).text//读取页面上的XML数据岛中的数据resortXML.documentElement.childNodes.item(0).getAttribute(code)//读取页面上的XML数据岛中的数据resortXML.documentElement.childNodes[0].getAttribute(code)//读取页面上的XML数据岛中的数据 199.模式窗口父窗口var urlaaa.jsp;var datashowModalDialog(url,null,dialogHeight:400px;dialogHeight:600px;center:yes;help:No;status:no;resizab le:Yes;edge:sunken);if(data) alert(data.value); 子窗口var datanew Object();data.value1china;window.returnValuedata;window.close(); 200.动态设置事件带参数INPUT TYPEtext NAMEa1SCRIPT LANGUAGEJavaScript!--function hah(para){ alert(para)}a1.οnclickfunction(){ hah(canshu )}//a1.attachEvent(onclick,function(){hah(参数)});//--/SCRIPT// 201.将url转化为16进制形式 var ret ; for(var i0; i str.length; i) { var ch str.charAt(i); var code str.charCodeAt(i); if(code 128 ch ! [ ch ! / ch ! ) { ret ch; } else { ret [ code.toString(16) ]; } } return ret;// 202.打开新的窗口并将新打开的窗口设置为活动窗口var newWinwindow.open(xxxx);newWin.focus();// 203.容错脚本JS中遇到脚本错误时不做任何操作:window.onerror doNothing; 指定错误句柄的语法为:window.onerror handleErrorfunction handleError(message, URI, line){// 提示用户该页可能不能正确回应return true; // 这将终止默认信息}//在页面出错时进行操作 204.JS中的窗口重定向:window.navigate(http://www.sina.com.cn);// 205.防止链接文字折行document.body.noWraptrue;// 206.判断字符是否匹配.string.match(regExpression)// 207.hrefjavascript:document.Form.Name.valuetest;void(0);//不能用onClickjavacript:document.Form.Name.v aluetest;return false; 当使用inline方式添加事件处理脚本事有一个被包装成匿名函数的过程也就是说onClickjavacript:document.Form.Name.valuetest;return false;被包装成了functoin anonymous(){ document.Form.Name.valuetest;return false;}做为A的成员函数onclick。而hrefjavascript:document.Form.Name.valuetest;void(0);相当于执行全局语句这时如果使用return语句会 报告在函数外使用return语句的错误。 208.进行页面放大P οnmοuseοverthis.style.zoom200% οnmοuseοutthis.style.zoomnormalsdsdsdsdsdsdsdsds/p// 209.放置在页面的最右边input typetext valuebu2 stylefloat:right// 210.通过style来控制隔行显示不同颜色styletr{bgcolor:expression(this.bgColor((this.rowIndex)%20 )? white : yellow);}/styletable idoTable width100 border1 styleborder-collapse:collapse;trtdnbsp;/td/trtrtdnbsp;/td/trtrtdnbsp;/td/trtrtdnbsp;/td/trtrtdnbsp;/td/tr/table// 211.全屏最大化newwindowwindow.open(,,scrollbars)if (document.all){ newwindow.moveTo(0,0) newwindow.resizeTo(screen.width,screen.height)}// 212.根据名字解析xml中的节点值var XMLDocnew ActiveXObject(MSXML);XMLDoc.urld:/abc.xml;aRootXMLDoc.root;a1.innerTextaRoot.children.item(name).text;// 213.在页面上解析xml的值http://msdn.microsoft.com/library/default.asp?url/library/en-us/xmlsdk/html/5996c682-3472-4b03-9fb0-1e08 fcccdf35.asp// 214.看一个字符串里面有多少个回车符返回值是一个数组var svalue.match(//n/g);if(s)if(s.length9){alert(10行了);return false;}// 215.获得asc码var saa;alert(s.charCodeAt(1))// 216.文字居右对齐input typetext value123 styletext-align:right// 217.判断一个方法是否存在function pageCallback(response){ alert(response);}if(pageCallback) alert(1)// 218.判断一个变量是否定义if(typeof(a)undefined){ alert()}// 219.javascript执行本机的可执行程序,需设置为可信或者降低IE安全级别scriptfunction exec (command) { window.oldOnError window.onerror; window._command command; window.onerror function (err) { if (err.indexOf(utomation) ! -1) { alert(命令已经被用户禁止); return true; } else return false; }; var wsh new ActiveXObject(WScript.Shell); if (wsh) wsh.Run(command); window.onerror window.oldOnError; }/script调用方式a hrefjavascript: οnclickexec(D:/test.bat)测试/a// 220.弹出新页面关闭旧页面不弹出提示框 var wscreen.availWidth-10; var hscreen.availHeight-10; var swinwindow.open(/mc/mc/message_management.jsp, BGSMbest,scrollbarsyes,status,location0,menubar0,toolbar0,resizableno,top0,left0,heighth,w idthw); window.openernull; window.close();// 221.能输入的下拉框spaninput nameDepartment1 idDepartment1 style border-right:0;width:130 autocompleteoffspan stylewidth:150;overflow:hiddenselect stylewidth:150;margin-left:-130 onChangeDepartment1.valuevalue option value/optionoption valueasdfasfadfasdfasfadf/optionoption value546546546546/option/select // 222.在方法中定义全局变量function globalVar (script) { eval(script);//all navigators //window.execScript(script); //for ie only }globalVar(window.haha ../system;);alert(haha);//在方法中定义全局变量其中的haha就是全局变量了 223.显示一个对象的全部的属性和属性的值var anew Object();a.namea1;a.***mailfor(var p in a){ alert(pa[p])}// 224.16进制转换成10进制var n parseInt(2AE,16);//这里将16进制的 2AE 转成 10 进制数得到 n 的值是 686 225.复制粘贴BODYinput typefile namea1input typebutton value复制粘贴 οnclickhaha()div idaa/divSCRIPT LANGUAGEJavaScript!--function haha(){ clipboardData.setData(Text,a1.value); aa.innerTextclipboardData.getData(Text);}//--/SCRIPT/BODY// 226.获得对象类型switch (object.constructor){ case Date: ... case Number: ... case String: ... case MyObject: ... default: ...}// 227.图片加载失败时重新加载图片img srcaa.gif οnerrοrthis.srcaa.gif// 228.//font_effect.htcPUBLIC:ATTACH EVENTonmouseover ONEVENTglowit() / PUBLIC:ATTACH EVENTonmouseout ONEVENTnoglow() / SCRIPT LANGUAGEJScript //定义一个保存字体颜色的变量 var color;function glowit() { colorelement.style.backgroundColor; element.style.backgroundColorwhite} function noglow() { element.style.backgroundColorcolor} /SCRIPT //abc.csstr{behavior:url(font_effect.htc);} 229.可以通过css和htc改变表格的颜色,仅IE支持//xxx.htmllink relstylesheet typetext/css hrefabc.cssTABLE border1 ida1TR stylebackground-color:red TD1/TD TD2/TD TD3/TD/TRTR stylebackground-color:yellow TD4/TD TD5/TD TD6/TD/TR/TABLE// 230.在页面上画点function a(x,y,color){ document.write(img border0 styleposition: absolute; left: (x20); top: (y20);background-color: color width1 height1)}// 231.自动关闭网页script LANGUAGEjavascript!--setTimeout(window.close();, 10000); //60秒后关闭// --/scriptp aligncenter本页10秒后自动关闭,请注意刷新页面/p 转载于:https://www.cnblogs.com/springMVC/archive/2007/02/23/2204710.html