摘要: function stopPropagation(e){ e=window.event||e; if(document.all){ e.cancelBubble=true; }else{ e.stopPropagation(); }}用法:document.getElementsByTagName("li")[0].onclick=function(e){ alert("li"); stopPropagation(e);} 阅读全文
posted @ 2012-02-23 11:11 码农13 阅读(176) 评论(0) 推荐(0) 编辑
摘要: function getEventTarget(e){ e=window.event||e; return e.srcElement||e.target;} 阅读全文
posted @ 2012-02-23 11:04 码农13 阅读(177) 评论(0) 推荐(0) 编辑
摘要: function setAlphaOpacity(elm,value){ elm=typeof elm=="string"?document.getElementById(elm):elm; if(document.all){ //IE elm.style.filter='alpha(opacity='+value+')'; }else{ //FF elm.style.opacity=value/100; }} 阅读全文
posted @ 2012-02-23 10:54 码农13 阅读(382) 评论(0) 推荐(0) 编辑
摘要: 找下一兄弟节点的兼容问题:FF会将空白、换行等文本信息也当做childNodes中的一员,而IE则会忽略它们,只将DOM节点当做是childNodes的一员。function getNextNode(node){ node=typeof node=="string"?document.getElementById(node):node; var nextNode=node.nextSibling; if(!nextNode)return null; if(!document.all){ //FF不识别document.all while(true){ if(nextNode 阅读全文
posted @ 2012-02-23 10:45 码农13 阅读(337) 评论(0) 推荐(0) 编辑
摘要: 1. JS 工具函数http://www.cnblogs.com/manong13/archive/2012/03/01/2375059.html2. JS 兼容问题http://www.cnblogs.com/manong13/archive/2012/03/01/2375060.html3. JS 编程思想http://www.cnblogs.com/manong13/archive/2012/03/01/2375061.html 阅读全文
posted @ 2012-02-23 09:54 码农13 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 输入:函数名function addLoadEvent(func){ var oldonload=window.onload; if("function"!=(typeof window.onload)){ window.onload=func; }else{ window.onload=function(){ oldonload(); func(); } }} 阅读全文
posted @ 2012-02-23 09:53 码农13 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 1. 添加。输入:元素,类名 function addClass(elm,newClass){ var classes = elm.className.split(' '); var classIndex=hasClass(elm,newClass); if(classIndex==-1)classes.push(newClass); elm.className = classes.join(' '); } 2. 查找。输入:元素,类名 返回:indexfunction hasClass(elm,className){ var classes = elm.... 阅读全文
posted @ 2012-02-23 09:48 码农13 阅读(322) 评论(0) 推荐(0) 编辑
摘要: //获取Cookie数组function getCookie(){ var array=new Array(); var cookies=document.cookie.split(/;/g); for(var i=0;i<cookies.length;i++){ var cookie=cookies[i]; if(cookie.indexOf("=")==-1){ continue; } var name=cookie.substring(0,cookie.indexOf("=")); ... 阅读全文
posted @ 2012-02-22 19:52 码农13 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 用CSS可以定义ul的自定义图标list-style:url(../images/sig1.jpg);在IE和FF下都能正常显示,但chrome不兼容。最好不要用这个属性,改为在li里定义背景图片:ul: list-style:none;li: background:url(../images/sig1.jpg) no-repeat; width:120px; 阅读全文
posted @ 2012-02-22 19:44 码农13 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 1.IE条件注释注:<!--[if IE]><![endif]--> 只在IE下有效<!--[if IE 6]><![endif]--> 只在IE6有效 7,8同理<!--[if gt IE 6]><![endif]--> 只在IE6以上版本有效 lte:<= lt:< gte:>= gt:> !:!=2.选择符前缀法:“*html” 前缀只对IE6生效 "*+html"前缀只对IE7生效.test{width:80px;} /*IE 6 7 8*/*html .test{wid 阅读全文
posted @ 2012-02-22 19:41 码农13 阅读(124) 评论(0) 推荐(0) 编辑