js技巧3

  1. 82.event.x,event.clientX,event.offsetX區別: 
  2. x:設置或者是得到鼠標相對於目標事件的父元素的外邊界在x座標上的位置。 clientX:相對於客戶區域的x座標位置,不 
  3.   
  4. 包括滾動條,就是正文區域。 offsetx:設置或者是得到鼠標相對於目標事件的父元素的內邊界在x座標上的位置。 
  5. screenX:相對於用戶屏幕。 
  6.   
  7.    
  8. 83.顯示是鼠標按鈕的哪個 
  9. <body onMouseDown="alert(event.button)">點Mouse看看// 
  10.   
  11. 84.打開C盤 
  12. <form action="file:///c|/"><input type="submit" value="c:\ drive"></form>// 
  13.    
  14. 85.當前屏幕的分辨率 
  15. screen.width、screen.height// 
  16.   
  17. 86.設置表格中的內容 
  18. tbl.rows[0].cells[1].innerText=document.form.text1.value;// 
  19.   
  20.    
  21. 87.本地快捷鍵 
  22. <p><a href="file:///::{208D2C60-3AEA-1069-A2D7-08002B30309D}" target="_blank">網上鄰居</a></p> 
  23. <p><a href="file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\d:\web" target="_blank">我的電腦</a></p> 
  24. <p><a href="file:///::{450D8FBA-AD25-11D0-98A8-0800361B1103}" target="_blank">我的文檔</a></p> 
  25. <p><a href="file:///::{645FF040-5081-101B-9F08-00AA002F954E}" target="_blank">回收站</a></p> 
  26. <p><a href="file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}" 
  27.   
  28. target="_blank">控制面板</a></p> 
  29. <p><a href="file:///::{7007ACC7-3202-11D1-AAD2-00805FC1270E}">撥號網絡</a>(windows 2000)</p> 
  30.   
  31.    
  32. 88.IE菜單 
  33. <button onclick="min.Click()"><font face="webdings">0</font></button>//改變按鈕上的圖片 
  34. <input type=button  onclick="document.execCommand('CreateLink','true','true')"> //創建新連接 
  35. <input type=button  onclick="document.execCommand('print','true','true')"> //打印 
  36. <input type=button  onclick="document.execCommand('saveas','true','網站製作.htm')">//另存爲htm 
  37. <input type=button  onclick="document.execCommand('saveas','true','網站製作.txt')">//另存爲txt 
  38. document.execCommand("SaveAs")//保存爲 
  39. document.execCommand('undo')//撤銷上一次操作 
  40.   
  41. 89.web對話框 
  42. <SCRIPT> 
  43. var contents='<style>body,td{font:menu}img{cursor:hand}</style>'
  44. contents+='<title>你要關閉我嗎</title>'; 
  45. contents+='<body bgcolor=menu>'; 
  46. contents+='<table width=100% height=100% border=0>'; 
  47. contents+='<tr><td align=center>'; 
  48. contents+='你要關閉我嗎?'; 
  49. contents+='<img src=dark.gif onclick=self.close() alt="...關閉">'; 
  50. contents+='<img src=jet.gif onclick=self.close() alt="全是關閉">'; 
  51. contents+='</td></tr></table>'; 
  52. showModalDialog("about:"+contents+"","","dialogHeight:50px;dialogWidth:250px;help:no;status:no") 
  53. document.write(contents); 
  54. </SCRIPT>// 
  55.   
  56. 90.取第x,y的值 
  57. <button onclick="t1.rows[x].cells[y].innerText='guoguo'"></button>// 
  58.   
  59. 91.向新打開的網頁上寫內容 
  60. newwin=window.open('about:blank','','top=10'); 
  61. newwin.document.write('');// 
  62.   
  63. 93.返回 
  64. javascript:history.go(-2);// 
  65.   
  66. 94.將頁面上選中的內容複製到剪貼板 
  67. abcdefg 
  68. <input type='button' 
  69.   
  70. onclick="window.clipboardData.setData('text',document.selection.createRange().text);" value='複製頁面選中 
  71.   
  72. 的字符'>// 
  73. 95.將頁面上選中的內容複製到剪貼板 
  74. <INPUT TYPE="text" NAME="">kjhkjhkhkj<INPUT TYPE="button" onclick="document.execCommand('Copy', 'false', 
  75.   
  76. null);">//// 
  77.   
  78. 96.鼠標移到下拉框時自動全部打開 
  79. <select onmouseover="javascript:this.size=this.length" onmouseout="javascript:this.size=1"></select>// 
  80.   
  81. 97.獲得本機的文件 
  82. var fso = new ActiveXObject("Scripting.FileSystemObject"); 
  83. var f1 = fso.GetFile("C:\\bsitcdata\\ejbhome.xml"); 
  84. alert("File last modified: " + f1.DateLastModified); // 
  85.   
  86. 98.判斷客戶端是否是IE瀏覽器 
  87. 因爲 document.all 是 IE 的特有屬性,所以通常用這個方法來判斷客戶端是否是IE瀏覽器 ,document.all?1:0; 
  88.   
  89. 99.創建新的下拉框選項 
  90. new Option(text,value)這樣的函數// 
  91.   
  92. 100.在頁面上畫柱狀圖 
  93. <STYLE> 
  94. td{font-size:12px} 
  95. body{font-size:12px} 
  96. v\:*{behavior:url(#default#VML);} //這裏聲明瞭v作爲VML公用變量 
  97. </STYLE> 
  98. <SCRIPT LANGUAGE="JavaScript"> 
  99. mathstr=12
  100. document.write ("<v:rect fillcolor='red' 
  101.   
  102. style='width:20;color:navy;height:"+5000/(1000/mathstr)+"'> %"+mathstr+"4人<v:Extrusion 
  103.   
  104. backdepth='15pt' on='true'/></v:rect>") 
  105. </SCRIPT> 
  106. <v:rect fillcolor='red' style='width:20;color:navy;height:200'>%124人<v:Extrusion 
  107.   
  108. backdepth='15pt' on='true'/></v:rect> 
  109. <v:rect fillcolor='yellow' style='width:20;color:navy;height:100'>%124人<v:Extrusion 
  110.   
  111. backdepth='15pt' on='true'/></v:rect>// 
  112.   
  113.    
  114.   
  115. 101.餅圖 
  116. <style> 
  117. v\:*     { behavior: url(#default#VML) } 
  118. o\:*     { behavior: url(#default#VML) } 
  119. .shape    { behavior: url(#default#VML) } 
  120. </style> 
  121. <script language="javascript"> 
  122. function show(pie) 
  123. pie.strokecolor=pie.fillcolor; 
  124. pie.strokeweight=10
  125. div1.innerHTML="<font size=2 color=red> " + pie.id +"</font> <font size=2>" + pie.title + "</font>"; 
  126. function hide(pie) 
  127. pie.strokecolor="white"
  128. pie.strokeweight=1
  129. div1.innerHTML=""
  130. </script> 
  131. </head> 
  132. <body> 
  133. <v:group style='width: 5cm; height: 5cm' coordorigin='0,0' coordsize='250,250'> 
  134. <v:shape id='asp技術' style='width:10;height:10;top:10;left:0' title='得票數:6 比例:40.00%' 
  135.   
  136. onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' 
  137.   
  138. CoordSize='10,10' strokecolor='white' fillcolor='#ffff33'><v:path v='m 300,200 ae 
  139.   
  140. 300,200,200,150,0,9437184 xe'/></v:shape> 
  141. <v:shape id='php' style='width:10;height:10;top:10;left:0' title='得票數:1 比例:6.67%' 
  142.   
  143. onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' 
  144.   
  145. CoordSize='10,10' strokecolor='white' fillcolor='#ff9933'><v:path v='m 300,200 ae 
  146.   
  147. 300,200,200,150,9437184,1572864 xe'/></v:shape> 
  148. <v:shape id='jsp' style='width:10;height:10;top:10;left:0' title='得票數:2 比例:13.33%' 
  149.   
  150. onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' 
  151.   
  152. CoordSize='10,10' strokecolor='white' fillcolor='#3399ff'><v:path v='m 300,200 ae 
  153.   
  154. 300,200,200,150,11010048,3145728 xe'/></v:shape> 
  155. <v:shape id='c#寫的.netWEB程序' style='width:10;height:10;top:10;left:0' title='得票數:3 比例:20.00%' 
  156.   
  157. onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' 
  158.   
  159. CoordSize='10,10' strokecolor='white' fillcolor='#99ff33'><v:path v='m 300,200 ae 
  160.   
  161. 300,200,200,150,14155776,4718592 xe'/></v:shape> 
  162. <v:shape id='vb.net寫的.netWEB程序' style='width:10;height:10;top:10;left:0' title='得票數:2 比例:13.33%' 
  163.   
  164. onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' 
  165.   
  166. CoordSize='10,10' strokecolor='white' fillcolor='#ff6600'><v:path v='m 300,200 ae 
  167.   
  168. 300,200,200,150,18874368,3145728 xe'/></v:shape> 
  169. <v:shape id='xml技術' style='width:10;height:10;top:10;left:0' title='得票數:1 比例:6.67%' 
  170.   
  171. onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' 
  172.   
  173. CoordSize='10,10' strokecolor='white' fillcolor='#ff99ff'><v:path v='m 300,200 ae 
  174.   
  175. 300,200,200,150,22020096,1572864 xe'/></v:shape> 
  176. </v:group> 
  177.   
  178. <v:group style='width: 6cm; height: 6cm' coordorigin='0,0' coordsize='250,250'> 
  179. <v:rect style='height:10;width:15;top:0;left:10' fillcolor='#ffff33'/> 
  180. <v:rect style='height:28;width:100;top:0;left:30' stroked='false'><v:textbox 
  181.   
  182. style='fontsize:2'>asp技術</v:textbox/></v:rect> 
  183. <v:rect style='height:10;width:15;top:30;left:10' fillcolor='#ff9933'/> 
  184. <v:rect style='height:28;width:100;top:30;left:30' stroked='false'><v:textbox 
  185.   
  186. style='fontsize:2'>php</v:textbox/></v:rect> 
  187. <v:rect style='height:10;width:15;top:60;left:10' fillcolor='#3399ff'/> 
  188. <v:rect style='height:28;width:100;top:60;left:30' stroked='false'><v:textbox 
  189.   
  190. style='fontsize:2'>jsp</v:textbox/></v:rect> 
  191. <v:rect style='height:10;width:15;top:90;left:10' fillcolor='#99ff33'/> 
  192. <v:rect style='height:28;width:100;top:90;left:30' stroked='false'><v:textbox 
  193.   
  194. style='fontsize:2'>c#寫的.netWEB程序</v:textbox/></v:rect> 
  195. <v:rect style='height:10;width:15;top:120;left:10' fillcolor='#ff6600'/> 
  196. <v:rect style='height:28;width:100;top:120;left:30' stroked='false'><v:textbox style='fontsize:2'>vb.net 
  197.   
  198. 寫的.netWEB程序</v:textbox/></v:rect> 
  199. <v:rect style='height:10;width:15;top:150;left:10' fillcolor='#ff99ff'/> 
  200. <v:rect style='height:28;width:100;top:150;left:30' stroked='false'><v:textbox style='fontsize:2'>xml技術 
  201.   
  202. </v:textbox/></v:rect> 
  203. </v:group> 
  204.   
  205. <div style="position: absolute; left: 10; top: 10; width: 760; height:16"> 
  206. <table border="1" cellpadding="2" cellspacing="2" cellpadding="0" cellspacing="0" 
  207.   
  208. style="border-collapse: collapse" bordercolor="#CCCCCC" width="100%" ID="Table1"> 
  209.   <tr> 
  210.    <td width="100%" id=div1> </td> 
  211.   </tr> 
  212. </table> 
  213. </div>// 
  214.   
  215. 102.是一個特殊的容器,想裝個網頁都行 
  216. <button><iframe src="http://www.google.com/"></iframe></button>//button 
  217.   
  218. 103.外部的html代碼 
  219. event.srcElement.outerHTML// 
  220.   
  221. 104.標識當前的IE事件的觸發器 
  222. event.srcElement和event.keyCode// 
  223.   
  224. 105.事件類型 
  225. event.type// 
發佈了31 篇原創文章 · 獲贊 3 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章