04 2013 档案

摘要:View Code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; ch 阅读全文
posted @ 2013-04-23 17:59 yexingwen 阅读(2208) 评论(0) 推荐(1)
摘要:View Code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; ch 阅读全文
posted @ 2013-04-23 17:55 yexingwen 阅读(895) 评论(0) 推荐(0)
摘要:View Code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; ch 阅读全文
posted @ 2013-04-23 17:54 yexingwen 阅读(714) 评论(0) 推荐(0)
摘要:search('a') 查找 返回的是位置,如果没有则返回-1substring 截取字符 substring(2,5) 2位开始,5结束,不包第5charAt 获取某个字符 charAt(0)split 分割字符正则表达式 JS写法:new RegExp('a','i') perl写法:var=/a/i;i 忽略大小写 如:var reg=/a/i;g 找到全部 如:var reg=/abcsaaa/g+ 若干 任意个.任意字符范围[abc]方括号内随便选哪个都行[a-z0-9]a到z 0到9[^a-z] ^排除,除了不少英文字母^不在方括号内 阅读全文
posted @ 2013-04-23 17:53 yexingwen 阅读(225) 评论(0) 推荐(0)
摘要:cookie思路:当点击登录按钮时,把cookie存起来,再次访问的时候就读取cookie,即把txt的value设置之前存起来cookie的值就行。View Code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head& 阅读全文
posted @ 2013-04-23 16:08 yexingwen 阅读(716) 评论(0) 推荐(1)
摘要:View Code /*设置cookie*/function setCookie(name, value, iDay){ var oDate=new Date(); oDate.setDate(oDate.getDate()+iDay); document.cookie=name+'='+value+';expires='+oDate;};/*使用方法:setCookie('user', 'simon', 11);*//*获取cookie*/function getCookie(name){ var arr=document.co 阅读全文
posted @ 2013-04-23 16:02 yexingwen 阅读(286) 评论(0) 推荐(0)
摘要:cookie设置过期时间要先获取当前的时间日期再加上过期时间就行。如:var oDate=new Date();oDate.setDate(oDate.getDate()+7); //设置过期时间document.cookie='user=admin;password=123546;expires='+oDate; 阅读全文
posted @ 2013-04-23 14:20 yexingwen 阅读(342) 评论(0) 推荐(0)
摘要:View Code window.onload=function(){ var txt=document.getElementById('txt'); var oBtn=document.getElementById('btn'); oBtn.onclick=function() { var oWindow=window.open('about:blank','_blank'); oWindow.document.write(txt.value); txt.value=''; };}; 1 <!DOCTYPE 阅读全文
posted @ 2013-04-12 17:47 yexingwen 阅读(520) 评论(0) 推荐(0)
摘要:可视区宽:document.documentElement.clientWidth可视区高:document.documentElement.clientHeight滚动距离:document.documentElement.scrollTop;document.documentElement只兼容FireFox IE 兼容Chrome要用document.bodyvar scrollTop=document.documentElement.scrollTop||document.body.scrollTop 阅读全文
posted @ 2013-04-12 17:41 yexingwen 阅读(212) 评论(0) 推荐(0)
摘要:View Code 1 window.onload=function() 2 { 3 new Drag('div1'); 4 new LimitDrag('div2'); 5 }; 6 7 function Drag(id) 8 { 9 this.disX=0;10 this.disY=0;11 var _this=this;12 this.oDiv=document.getElementById(id);13 14 this.oDiv.onmousedown=function(ev)15 {16 _t... 阅读全文
posted @ 2013-04-11 17:47 yexingwen 阅读(417) 评论(0) 推荐(0)
摘要:内置对象(静态对象)是不用通过new来实例化出来的,如:Math.ceil()内置对象(静态对象)Math Global本地对象(非静态对象)是通过new实例化出来的,如:var obj=new Object();常用的本地对象(非静态对象)有:Object Function Array String Boolean Number Date RegExp Error 阅读全文
posted @ 2013-04-11 17:01 yexingwen 阅读(200) 评论(0) 推荐(0)
摘要:View Code window.onload=function(){ new Tab('div1');};function Tab(id){ var _this=this; var oDiv=document.getElementById(id); this.aBtn=oDiv.getElementsByTagName('input'); this.aDiv=oDiv.getElementsByTagName('div'); for(var i=0;i<this.aBtn.length;i++) { ... 阅读全文
posted @ 2013-04-11 11:25 yexingwen 阅读(191) 评论(0) 推荐(0)
摘要:用构造函数里面加属性function CreatePerson(name,qq){this.name=name;this.qq=qq;}用原型里面加方法 原型相当于CSS的class,就是给一组元素添加方法CreatePerson.protpype.showName=function(){alert(name);};CreatePerson.protpype.showQQ=function(){alert(qq);}新new一个变量var obj=new CreatePerson('Simon','460024241');var obj2=new CreateP 阅读全文
posted @ 2013-04-10 23:38 yexingwen 阅读(191) 评论(0) 推荐(0)
摘要:Ajax工作步骤:1、创建Ajax对象2、连接服务器3、发送请求4、接收返回值JS的同步:事情一件一件来JS异步:事情可以一起坐创建Ajax:var oAjax=new XMLHttpRequest(); //除IE6以为的浏览器var oAjax=new ActiveXObject("Microsoft.XMLHttp"); //IE6 阅读全文
posted @ 2013-04-03 16:58 yexingwen 阅读(127) 评论(0) 推荐(0)
摘要:IE9以下浏览器当页面有文字和图片等多个元素的时候,拖拽可能会选中了文字。事件捕获:setCapture() 只在IE下才起作用的。作用是把页面所有元素事件都指向当前对象事件。例如:aBtn.setCapture(); 就是把页面所有事件都指向了按钮对象,不管在页面按哪个位置都会触发按钮的函数。<script>window.onload=function(){ var oBtn=document.getElementById('btn'); oBtn.onclick=function() { alert('a'); }; oBtn.setCaptur 阅读全文
posted @ 2013-04-02 17:14 yexingwen 阅读(448) 评论(0) 推荐(0)