js应用2

xml 代码
  1. 1.文本框焦点问题   
  2. onBlur:当失去输入焦点后产生该事件   
  3. onFocus:当输入获得焦点后,产生该文件   
  4. Onchange:当文字值改变时,产生该事件   
  5. Onselect:当文字加亮后,产生该文件   
  6.   
  7. <input type="text" value="郭强" onfocus="if(value=='郭强') {value=''}" onblur="if    
  8. (value=='') {value='郭强'}">点击时文字消失,失去焦点时文字再出现   
  9.   
  10.   
  11. 2.网页按钮的特殊颜色   
  12. <input type=button name="Submit1" value="郭强" size=10 class=s02    
  13.   
  14. style="background-color:rgb(235,207,22)">  
  15.   
  16. 3.鼠标移入移出时颜色变化   
  17. <input type="submit" value="找吧" name="B1" onMouseOut=this.style.color="blue"    
  18.   
  19. onMouseOver=this.style.color="red"  class="button">  
  20.   
  21. 4.平面按钮   
  22. <input type=submit value=订阅 style="border:1px solid :#666666; height:17px; width:25pt; font-size:9pt;    
  23.   
  24. BACKGROUND-COLOR: #E8E8FF; color:#666666" name="submit">  
  25.   
  26. 5.按钮颜色变化   
  27. <input type=text name="nick"  style="border:1px solid #666666;  font-size:9pt;  height:17px;    
  28.   
  29. BACKGROUND-COLOR: #F4F4FF; color:#ff6600" size="15" maxlength="16">  
  30.   
  31. 6.平面输入框   
  32. <input type="text" name="T1" size="20" style="border-style: solid; border-width: 1">  
  33.   
  34. 7.使窗口变成指定的大小   
  35. <script>  
  36. window.resizeTo(300,283);   
  37. </script>  
  38.   
  39. 8.使文字上下滚动   
  40. <marquee direction=up scrollamount=1 scrolldelay=100 onmouseover='this.stop()' onmouseout='this.start()'    
  41.   
  42. height=60>  
  43. <!-- head_scrolltext -->  
  44. <tr>  
  45. <td>  
  46. 共和国   
  47. </table>        <!-- end head_scrolltext -->  
  48. </marquee>  
  49.   
  50. 9.状态栏显示该页状态   
  51. <base onmouseover="window.status='网站建设 http://www.webmake.cn/' ;return true">  
  52.   
  53. 10.可以点击文字实现radio选项的选定   
  54. <br>  
  55. &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="regtype" value="A03" id="A03">  
  56. <label for="A03"> 情侣 : 一次注册两个帐户</label> <br>  
  57.   
  58. 11.可以在文字域的font写onclick事件   
  59.   
  60. 12.打印</a>打印网页   
  61. <a href='javascript:window.print ()'>  
  62.   
  63. 13.线型输入框   
  64. <input type="text" name="key"  size="12" value="关键字" onFocus=this.select() onMouseOver=this.focus()    
  65.   
  66. class="line">  
  67.   
  68. 14.显示文档最后修改日期   
  69. <script language=javascript>  
  70. function hi(str)   
  71. {   
  72.  document.write(document.lastModified)   
  73.   
  74.  alert("hi"+str+"!")   
  75. }   
  76. </script>  
  77.   
  78. 15.可以在鼠标移到文字上时就触发事件   
  79. <html>  
  80. <head>  
  81. <script language="LiveScript">  
  82. <!-- Hiding   
  83.      function hello() {   
  84.        alert("哈罗!");   
  85.      }   
  86. </script>  
  87. </head>  
  88. <body>  
  89. <a href="" onMouseOver="hello()">link</a>  
  90. </body>  
  91. </html>  
  92.   
  93. 16.可以根据网页上的选项来确定页面颜色   
  94. <HTML>  
  95. <HEAD>  
  96.  <TITLE>background.html</TITLE>  
  97. </HEAD>  
  98. <SCRIPT>  
  99. <!--   
  100.   
  101. function bgChange(selObj) {   
  102.  newColor = selObj.options[selObj.selectedIndex].text;   
  103.  document.bgColor = newColor;   
  104.  selObj.selectedIndex = -1;   
  105.  }   
  106.   
  107. //-->  
  108. </SCRIPT>  
  109. <BODY STYLE="font-family:Arial">  
  110. <B>Changing Background Colors</B>  
  111. <BR>  
  112.  <FORM>  
  113.   <SELECT SIZE="8" onChange="bgChange(this);">  
  114.   <OPTION>Red   
  115.   <OPTION>Orange   
  116.   <OPTION>Yellow   
  117.   <OPTION>Green   
  118.   <OPTION>Blue   
  119.   <OPTION>Indigo   
  120.   <OPTION>Violet   
  121.   <OPTION>White   
  122.  <OPTION>pink   
  123.   </SELECT>  
  124.  </FORM>  
  125. </BODY>  
  126. </HTML>  
  127.   
  128. 17.将按钮的特征改变   
  129. <style type="text/css">  
  130. <!--   
  131. .style1 { font-size: 12px; background: #CCCCFF; border-width: thin thin thin thin; border-color: #CCCCFF    
  132.   
  133. #CCCCCC #CCCCCC #CCCCFF}   
  134. .style2 { font-size: 12px; font-weight: bold; background: #CCFFCC; border-width: thin medium medium thin;    
  135.   
  136. border-color: #CCFF99 #999999 #999999 #CCFF99}   
  137. -->  
  138. </style>    
  139.   本例按钮的代码如下:   
  140. <input type="submit" name="Submit" value="提 交" onmouseover="this.className='style2'"    
  141.   
  142. onmouseout="this.className='style1'" class="style1">    
  143.   
  144. 18.改变按钮的图片.   
  145. <style type="text/css">  
  146. <!--   
  147. .style3 { font-size: 12px; background: url(image/buttonbg1.gif); border: 0px; width: 60px; height: 22px}   
  148. .style4 { font-size: 12px; font-weight: bold; background: url(image/buttonbg2.gif); border: 0px 0; width:    
  149.   
  150. 60px; height: 22px}   
  151. -->  
  152. </style>    
  153.   本例的按钮代码如下:    
  154. <input type="submit" name="Submit2" value="提 交" onmouseover="this.className='style4'"    
  155.   
  156. onmouseout="this.className='style3'" class="style3">  
  157.   
  158. 19.打印页面   
  159. <div align="center"><a class=content href="javascript:doPrint();">打印本稿</a></div>  
  160.   
  161. 20.可以直接写html语言   
  162. document.write("");   
  163.   
  164. 21.改变下拉框的颜色   
  165. <select name="classid"    
  166.   
  167. onChange="changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)"    
  168.   
  169. size="1" style="color:#008080;font-size: 9pt">    
  170.   
  171. 22.转至目标URL   
  172. window.location="http://guoguo"  
  173.   
  174. 23.传递该object的form   
  175. UpdateSN('guoqiang99267',this.form)    
  176. function UpdateSN(strValue,strForm)   
  177. {   
  178.   strForm.SignInName.value = strValue;   
  179.   return false;   
  180. }   
  181.   
  182. 24.文字标签   
  183. <label for="AltName4"><input name="AltName" type="RADIO" tabindex="931"  id="AltName4"    
  184.   
  185. >guoqiang99859</label>  
  186.   
  187. 25.layer2为组件的ID,可以控制组件是否可见   
  188. document.all.item('Layer2').style.display = "block";   
  189. document.all.item('Layer2').style.display = "none";//   
  190.   
  191. 26.将页面加入favorite中   
  192. <script language=javascript>    
  193. <!--    
  194. function Addme(){    
  195. url = "http://your.site.address"; //你自己的主页地址    
  196. title = "Your Site Name"; //你自己的主页名称    
  197. window.external.AddFavorite(url,title);    
  198. -->    
  199. </script>//    
  200.   
  201. 27.过10秒自动关闭页面   
  202. < script language="JavaScript" >  
  203. function closeit() {   
  204. setTimeout("self.close()",10000)   
  205. }   
  206. < /script >  
  207.   
  208. 28.可以比较字符的大小   
  209. char=post.charAt(i);   
  210. if(!('0'<=char&&char<='9'))   
  211.   
  212. 29.将字符转化为数字   
  213. month = parseInt(char)   
  214.   
  215. 30.点击value非空的选项时转向指定连接   
  216.  <select onchange='if(this.value!="")window.open(this.value)' class="textinput">  
  217.     <option selected>主办单位</option>  
  218.     <option>-----------------</option>  
  219.     <option value="http://www.bjd.com.cn/">北京日报</option>  
  220.     <option value="http://www.ben.com.cn/">北京晚报</option>  
  221. </select>  
  222.   
  223. 31.改变背景颜色   
  224. <td width=* class=dp bgColor=#FAFBFC onmouseover="this.bgColor='#FFFFFF';"    
  225.   
  226. onmouseout="this.bgColor='#FAFBFC';">  
  227.   
  228. 32.改变文字输入框的背景颜色   
  229. <style>  
  230. .input2 {background-image: url('../images/inputbg.gif');   font-size: 12px; background-color:    
  231.   
  232. #D0DABB;border-top-width:1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}   
  233. </style>  
  234. <input name=content type=text size="47" class="input2" maxlength="50">  
  235.   
  236. 33.改变水平线的特征   
  237. <hr size="0" noshade color="#C0C0C0">  
  238.   
  239. 34.传递参数的方式   
  240. <a href="vote.asp?CurPage=8&id=3488">8</a>  
  241.   
  242. 35.页内跳转   
  243. <a href="#1">1</a>  
  244. <a href="#2">2</a>  
  245. <a href="#3">3</a>  
  246. <a href="#4">4</a>  
  247. <a href="#5">5</a>  
  248. <a href="#6">6</a>  
  249. <a href="#7">7</a>  
  250. <a name="1">dfdf</a>  
  251. <a name="2">dfdf</a>//   
  252.   
  253. 36.两个按键一起按下   
  254. if(event.ctrlKey && window.event.keyCode==13)//   
  255.   
  256. 37.刷新页面   
  257. javascript:this.location.reload()//   
  258.   
  259. 38.将网页的按钮使能   
  260. <SCRIPT LANGUAGE="JavaScript">  
  261. function haha()   
  262. {   
  263.  for(var i=0;i<document.form1.elements.length;i++)   
  264.  {   
  265.   if(document.form1.elements[i].name.indexOf("bb")!=-1)   
  266.    document.form1.elements[i].disabled=!document.form1.elements[i].disabled;   
  267.  }   
  268. }   
  269. </SCRIPT>  
  270. <BODY><form name=form1>  
  271. <INPUT TYPE="button" NAME="aa "  value=cindy onclick=haha()>  
  272. <INPUT TYPE="button" NAME="bb " value=guoguo>  
  273. <INPUT TYPE="button" NAME="bb " value=guoguo>  
  274.   
  275. 39.文字移动   
  276. <marquee scrollamount=3 onmouseover=this.stop(); onmouseout=this.start();>  
  277.   
  278. 40.双击网页自动跑   
  279. <SCRIPT LANGUAGE="JavaScript">  
  280. var currentpos,timer;    
  281. function initialize()    
  282. {    
  283.  timer=setInterval("scrollwindow()",1);   
  284. }    
  285. function sc()   
  286. {   
  287.  clearInterval(timer);   
  288. }   
  289. function scrollwindow()    
  290. {   
  291.  currentpos=document.body.scrollTop;   
  292.  window.scroll(0,++currentpos);   
  293.  if (currentpos != document.body.scrollTop)    
  294.   sc();   
  295. }    
  296. document.onmousedown=sc  
  297. document.ondblclick=initialize  
  298. </SCRIPT>//   
  299.   
  300. 41.后退   
  301. <INPUT TYPE="button" onclick=window.history.back() value=back>  
  302.   
  303. 42.前进   
  304. <INPUT TYPE="button" onclick=window.history.forward() value=forward>  
  305.   
  306. 43.刷新   
  307. <INPUT TYPE="button" onclick=document.location.reload() value=reload>  
  308.   
  309. 44.转向指定网页   
  310. document.location="http://ww"或者document.location.assign("http://guoguo.com")   
  311.   
  312. 45.在网页上显示实时时间   
  313. <SCRIPT LANGUAGE="JavaScript">  
  314. var clock_id;   
  315. window.onload=function()   
  316. {   
  317.  clock_id=setInterval("document.form1.txtclock.value=(new Date);",1000)   
  318. }   
  319. </SCRIPT>//   
  320.   
  321. 46.可以下载文件    
  322. document.location.href="目标文件"//   
  323.   
  324. 47.连接数据库   
  325. import java.sql.*;   
  326. String myDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";   
  327. Class.forName(myDBDriver);   
  328. Connection conn=DriverManager.getConnection("jdbc:odbc:firm","username","password");   
  329. Statement stmt=conn.createStatement();   
  330. ResultSet rs=stmt.executeQuery(sql);   
  331. rs.getString("column1");//   
  332.   
  333. 48.可以直接在页面“div”内写下所需内容   
  334. <INPUT TYPE="button" onclick="a1.innerHTML='<font color=red>*</font>'">  
  335. <div id=a1></div>//   
  336.   
  337. 49.可以改变页面上的连接的格式,使其为双线   
  338. <style>  
  339. A:link {text-decoration: none; color:#0000FF; font-family: 宋体}   
  340. A:visited {text-decoration: none; color: #0000FF; font-family: 宋体}   
  341. A:hover {text-decoration: underline overline; color: FF0000}   
  342. </style>  
  343.   
  344. <style>  
  345. A:link {text-decoration: none; color:#0000FF; font-family: 宋体}   
  346. A:visited {text-decoration: none; color: #0000FF; font-family: 宋体}   
  347. A:hover {text-decoration: underline overline line-through; color: FF0000}   
  348. TH{FONT-SIZE: 9pt}   
  349. TD{FONT-SIZE: 9pt}   
  350. body {SCROLLBAR-FACE-COLOR: #A9D46D; SCROLLBAR-HIGHLIGHT-COLOR: #e7e7e7;SCROLLBAR-SHADOW-COLOR:#e7e7e7;    
  351.   
  352. SCROLLBAR-3DLIGHT-COLOR: #000000; LINE-HEIGHT: 15pt; SCROLLBAR-ARROW-COLOR: #ffffff;    
  353.   
  354. SCROLLBAR-TRACK-COLOR: #e7e7e7;}   
  355.   
  356. INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE:    
  357.   
  358. 9pt; BORDER-LEFT-COLOR: #cccccc;    
  359. BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc;    
  360.   
  361. PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc}   
  362. DIV,form ,OPTION,P,TD,BR{FONT-FAMILY: 宋体; FONT-SIZE: 9pt}    
  363. textarea, select {border-width: 1; border-color: #000000; background-color: #efefef; font-family: 宋体;    
  364.   
  365. font-size: 9pt; font-style: bold;}   
  366. .text { font-family: "宋体"; font-size: 9pt; color: #003300; border: #006600 solid; border-width: 1px 1px    
  367.   
  368. 1px 1px}   
  369. </style>完整的css   
  370.   
  371.   
  372. 50.新建frame   
  373. <a    
  374.   
  375. href="javascript:newframe('http://www.163.net/help/a_little/index.html','http://www.163.net/help/a_little   
  376.   
  377. /a_13.html')"><img alt=帮助 border=0 src="http://bjpic.163.net/images/mail/button-help.gif"></a>  
  378.   
  379. 51.向文件中写内容   
  380. <%@ page import="java.io.*" %>  
  381. <%   
  382.  String str = "print me";   
  383.  //always give the path from root. This way it almost always works.   
  384.  String nameOfTextFile = "/usr/anil/imp.txt";   
  385.  try   
  386.  {    
  387.   PrintWriter pw = new PrintWriter(new FileOutputStream(nameOfTextFile));   
  388.   pw.println(str);   
  389.   //clean up   
  390.   pw.close();   
  391.  }   
  392.  catch(IOException e)   
  393.  {   
  394.   out.println(e.getMessage());   
  395.  }   
  396. %>  
  397.   
  398. 52.先读文件再写文件   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值