辟邪剑谱之JavaScript

 辟邪剑谱之JavaScript:

  1. 1、var result=this.req.responseText;
  2. 2、js的typeof可以获得变量的类型 typeof objResult=='string' 
  3. 3、js的 for(var obj in objResult){}
  4. 4、 Dialog.Open('DVLevelSpeakSpace',this,true,true,'middle center');
  5. 5、div.attachEvent('onclick', EventHandler);
  6. 6、在JavaScript中this是始终指向正在被执行的方法的“owner”(宿主),或者是包含这个方法的对象本身。
  7. 7、obj.removeAttribute("属性")
  8. 8、string.Format("{0}",bianliang)
  9. 9、file.value.toLowerCase
  10. 10、javascript 的history对象 
  11.      history.back() 等同于按浏览器的后退按钮 
  12.      history.forward() 等同于按浏览器的前进按钮 
  13.      history.current 指当前的url(等同于location.href), 
  14.      在历史中的索引位置总为 0 
  15.      history.go(-2)或 history.go("任意.html") 向前或向后移动, 
  16.      或查找字符串标明的最新url
  17. 11、parentTextEdit 获取文档层次中可用于创建包含原始对象的 TextRange 的容器对象。
  18. 12、Node 集合:
  19.     document.createTextNode("abcd");
  20.     object.parentNode.removeChild(obj);
  21.     this.childNodes[];              object.nodeValue;object.nodeType;
  22.     this.removeNode(true);  object.firstChild.swapNode(obj.lastChild);
  23.      
  24.     document.getElementById("myOL").replaceNode(oldNode); 
  25.     当 object 被替换时,所有与之相关的属性内容都将被移除。
  26.     .cloneNode(false));
  27. 13、 Child 方法集合 :
  28.      父对象.firstChild;        父对象.lastChild
  29.      父对象.appendChild(对象);        父对象.removeChild(对象)
  30.      document.getElementById("myUL").replaceChild(newItem, lastChild);
  31.      父对象.childNodes[n]
  32. 14、 Element 集合:
  33.      document.getElementById();  document.getElementsByName() 返回集合;
  34.      document.getElementsByTagName(标签) 返回集合;
  35.      applyElement()  object . applyElement ( oElement , sWhere ) 
  36.      让object成为oElement 的父对象或子对象。 sWhere :  可选项。字符串(String)。          outside(父) | inside(子) outside :  默认值。将 oElement 添加为 object 的父对象 
  37.      document.elementFromPoint(event.x,event.y).tagName=="TD 
  38.      event.srcElement.id;
  39. 15、uniqueID(微软内部元素id)  
  40. 16、innerText;  innerHTML;  outerHTML(外壳也显了);
  41. 17、newWindow=window.open("","","width=250,height=250");newWindow.focus();     newWindow.blur()     窗口为焦点  窗口失去焦点
  42. 18、对象.componentFromPoint(x,y) 鼠标点的地方是在(outsize) 还是内
  43.    document.getElementById("myTextarea").componentFromPoint(x,y)
  44. 19、window.status
  45. 20、window对象集合:
  46.     window.document; window.location; window.navigator;window.screen
  47. 21、对象.getBoundingClientRect().right(对象位置)  
  48.     getClientRects[n] 获取描述对象内容或客户区内布局的矩形集合。每个矩形都描述了一条直线
  49. 22、newInputElem.mergeAttributes(form.field1);//复制field1的所有读写属性 到newInputElem对象 
  50. 23、Attribute 系列集合
  51.     mergeAttributes
  52.     newInputElem.mergeAttributes(form.field1);//复制field1的所有读写属性 到newInputElem对象 
  53. 24、.clientHeight, clientWidth: (可见区 框里高、宽包括padding 不包括margin、边框厚)
  54.     这两个属性大体上显示了元素内容的象素高度和宽度.理论上说这些测量不考虑任何通过样式表加入 
  55.     元素中的页边距,边框等. 
  56.     
  57.    .clientLeft,clientTop: (边框的厚)
  58.    这两个返回的是元素周围边框的厚度,如果不指定一个边框或者不定位改元素,他的值就是0. 
  59.    .offsetWidth(宽  内容+padding+边框厚)
  60.    .scrollLeft,scrollTop: (水平、垂直 滚了多远)
  61.    如果元素是可以滚动的,可以通过这俩个属性得到元素在水平和垂直方向上滚动了多远,单位是象素. 
  62.    对于不可以滚动的元素,这些值总是0. 
  63.    scrollHeight,scrollWidth: 
  64.    不管有多少对象在页面上可见,他们得到的是整体. 
  65.    style.left: (包含它的 左边距离)
  66.    定位元素与包含它的矩形左边界的偏移量 
  67.    style.piexlWidth(内容的宽 不包括padding)
  68.    style.pixelLeft: 
  69.    返回定位元素左边界偏移量的整数像素值.因为属性的非像素值返回的是包含单位的字符串,例如,30px. 利用这个属性可以单独处理
  70.    以像素为单位的数值. 
  71.    style.posLeft: 
  72.    返回定位元素左边界偏移量的数量值,不管相应的样式表元素指定什么单位.因为属性的非位置值返回的是包
  73.    含单位的字符串,例如,1.2em   
  74.    <SCRIPT LANGUAGE="JavaScript">
  75. var  s = "";
  76. s += "/n网页可见区域宽:"+ document.body.clientWidth;
  77. s += "/n网页可见区域高:"+ document.body.clientHeight;
  78. s += "/n网页可见区域宽:"+ document.body.offsetWidth  +" (包括边线的宽)";
  79. s += "/n网页可见区域高:"+ document.body.offsetHeight +" (包括边线的宽)";
  80. s += "/n网页正文全文宽:"+ document.body.scrollWidth;
  81. s += "/n网页正文全文高:"+ document.body.scrollHeight;
  82. s += "/n网页被卷去的高:"+ document.body.scrollTop;
  83. s += "/n网页被卷去的左:"+ document.body.scrollLeft;
  84. s += "/n网页正文部分上:"+ window.screenTop;
  85. s += "/n网页正文部分左:"+ window.screenLeft;
  86. s += "/n屏幕分辨率的高:"+ window.screen.height;
  87. s += "/n屏幕分辨率的宽:"+ window.screen.width;
  88. s += "/n屏幕可用工作区高度:"+ window.screen.availHeight;
  89. s += "/n屏幕可用工作区宽度:"+ window.screen.availWidth;
  90. alert(s);
  91. </SCRIPT>
  92. 25、tr=table.insertRow();
  93.     td=tr.insertCell();
  94.     td.setAttribute("width","380");
  95.     td.style.backgroundColor="#EFEFEF";
  96. 26、NodeA.firstChild = NodeA1 
  97. NodeA.lastChild = NodeA3 
  98. NodeA.childNodes.length = 3 
  99. NodeA.childNodes[0] = NodeA1 
  100. NodeA.childNodes[1] = NodeA2 
  101. NodeA.childNodes[2] = NodeA3 
  102. NodeA1.parentNode = NodeA 
  103. NodeA1.nextSibling = NodeA2 
  104. NodeA3.prevSibling = NodeA2 
  105. NodeA3.nextSibling = null 
  106. NodeA.lastChild.firstChild = NodeA3a 
  107. NodeA3b.parentNode.parentNode = NodeA
  108.   tr.insertBefore(td1,td2); //在tr的节点集合里有td2  在td2前面插入新节点td1
  109.   td1.insertBefore(td2);   // 原来的td2就消失了
  110. 27、escape("字符串")  可以用unescape()方法来反编译经过escape()加密过的字符串
  111.     到C#中也可以用Server.UrlDecode("字符串")解码;
  112. 28、//javascript 去掉两边空格 
  113. function trimString(str) 
  114. var i,j; 
  115. if(str == ""return ""
  116. for(i=0;i<str.length;i++) 
  117. if(str.charAt(i) != ' 'break
  118. if(i >= str.length) return ""
  119. for(j=str.length-1;j>=0;j--) 
  120. if(str.charAt(j) != ' 'break
  121. return str.substring(i,j+1); 
  122. 29、中的字符型转换成数值型:parseInt(str),parseFloat()
  123. 30、<script>window.location.href='http://www.xrss.cn';</script>
  124. 31、//javascript 去掉两边空格 
  125. function trimString(str) 
  126. var i,j; 
  127. if(str == ""return ""
  128. for(i=0;i<str.length;i++) 
  129. if(str.charAt(i) != ' 'break
  130. if(i >= str.length) return ""
  131. for(j=str.length-1;j>=0;j--) 
  132. if(str.charAt(j) != ' 'break
  133. return str.substring(i,j+1); 
  134. }
  135. 32、打开一个没有菜单的窗口
  136.  <a οnclick="javascript:window.open('jiaotongpic.aspx','rese lect','resizable=yes,scrollbars=no,status=no,toolbar=no,menubar=no,width=409px,height=280px,location=no');">
  137. 33、<input type="button" onClick="window.opener = '';window.close();" value="IE6最简单的无提示关闭窗口" >
  138. 34、 Response.Write("<script>top.location='login.aspx';window.parent.reload()</script>"); 
  139. 35、window.frames['ifrm01'].src='b.htm'
  140. 36、 取消定时执行 function hello() {  window.alert(“Hello”);}
  141.                   var myTimeout = window.setTimeout(“hello()”,5000);
  142.                   window.clearTimeout(myTimeout);
  143. 37、输出日期 var thisDate = new Date(); document.write(thisDate.toString());
  144. 38、设置日期输出格式
  145.  var thisDate = new Date();
  146.  var thisTimeString = thisDate.getHours() + “:” + thisDate.getMinutes();
  147.  var thisDateString = thisDate.getFullYear() + “/” + thisDate.getMonth() + “/” + thisDate.getDate();
  148.  document.write(thisTimeString + “ on “ + thisDateString); 
  149. 39、读取URL参数
  150.  var urlParts = document.URL.split(“?”);
  151.  var parameterParts = urlParts[1].split(“&”);
  152.  for (i = 0; i < parameterParts.length; i++) { 
  153.  var pairParts = parameterParts[i].split(“=”);
  154.  var pairName = pairParts[0];
  155.  var pairValue = pairParts[1];
  156.  document.write(pairName + “ :“ +pairValue );
  157. 40、页面跳转 window.location = “http://www.liu21st.com/”;
  158. 44、在框架页面之间共享脚本 parent.frame1.doAlert()
  159. 45、页面刷新 οnclick="javascript:location.reload(true)"
  160. 46、tableid.cells[]表示表格的单元格集合  tableid.childNodes[0].innerHTML 表示的是table第一个tr里的内容
  161.     tableid.childNodes[0].childNodes[0].innerHTML 表示的是table第一个tr里的第一个tbody里的内容
  162.     tableid.childNodes[0].childNodes[0].childNodes[0].innerHTML 表示的是table第一个tr里的第一个tbody第一个td里的内容
  163. 47、 setInterval("isSecueed()",50)  每隔0.05秒执行一下 isSecueed()     window.clearInterval(Form.Timeval);是用来取消的
  164. 48、HttpCookie.GetCookie("Picture_"+curCmd._guid);  JS中cookie的添加     HttpCookie.Flush()    HttpCookie.DelCookie("Picture_"+curCmd._guid);
  165. 49、Ajax.Request('/Family/Album/Upload.aspx',Form.onUploadedCallback,null,xmlData,'Text','xml','element'); 传xmlData构建 用ajax
  166. 50、对象.parentNode      就是对象的父对象
  167. 51、Js 构建对象  对象下面建属性 属性(命令池、类、数组、全局变量)
  168. var Form = {
  169.     CmdPool:{},
  170.     CmdKeys:[],
  171.     CmdIndex:0,
  172.     Command:function(id,target,src,fName,guid,albumId){
  173.         this._id = id;}
  174. 52、style="cursor: hand;"
  175. 53、获取script集合第一个元素 document.scripts[0]
  176. 54、search 得到的是url中query部分
  177. <script language="javascript"
  178. alert(window.location.search.substr(1).split("&")) 
  179. </script> 
  180. <a href="1.htm?topic=1&id=2">测试</a>
  181. 55、对象.insertBefore(newChild,一节点)   在'一节点'子节点前插入 newChild子节点
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值