06 2011 档案

iframe高度自适应
摘要:varadjustIframe=function(id){variframe=document.getElementById(id)varidoc=iframe.contentWindow&&iframe.contentWindow.document||iframe.contentDocument;varcallback=function(){variheight=Math.max(idoc.body.scrollHeight,idoc.documentElement.scrollHeight);//取得其高iframe.style.height=iheight+"p 阅读全文

posted @ 2011-06-16 09:54 wuye1200 阅读(174) 评论(0) 推荐(0)

数组去重记录下
摘要:Array.prototype.distinct=function(){varret=[];for(i=0,ii=this.length;i<1*ii;i++){for(j=i+1;j<1*this.length;){if(this[i]===this[j]){ret.push(this.splice(j,1)[0]);}else{j++;}}}this.ret=ret;returnthis;}//测试alert(['a','b','c','c','d','b','a', 阅读全文

posted @ 2011-06-14 12:30 wuye1200 阅读(179) 评论(0) 推荐(0)

微博插入话题
摘要:效果的实现文字的选中功能是不太常用的功能,多出现在文本编辑器中,或是文本域之类的光标处理上。所以呢,使用的一些属性也并不是常见的。在IE浏览器下使用的是createTextRange而Firefox/chrome等现代浏览器下使用的是setSelectionRange。假设文本域对象的名称是obj,则在IE及非IE浏览器下实现指定文字选中的代码如下:IE浏览器下: var range = obj.createTextRange();range.moveStart("character", 开始序号);range.moveEnd("character", 阅读全文

posted @ 2011-06-14 09:59 wuye1200 阅读(260) 评论(0) 推荐(0)

封装常用代码
摘要:getElementsByClassName附上一片关于getElementsByClassName的文章一篇 http://hszy00232.blog.163.com/blog/static/43022753201042051443548/functiongetElementsByClassName(oElem,strTagName,strClassName){vararrElements=(strTagName=='*'&&oElem.all)?oElem.all:oElem.getElementsByTagName(strTagName);varretu 阅读全文

posted @ 2011-06-02 11:59 wuye1200 阅读(281) 评论(0) 推荐(0)

浏览器版本
摘要:varSys={};varua=navigator.userAgent.toLowerCase();vars;(s=ua.match(/msie([\d.]+)/))?Sys.ie=s[1]:(s=ua.match(/firefox\/([\d.]+)/))?Sys.firefox=s[1]:(s=ua.match(/chrome\/([\d.]+)/))?Sys.chrome=s[1]:(s=ua.match(/opera.([\d.]+)/))?Sys.opera=s[1]:(s=ua.match(/version\/([\d.]+).*safari/))?Sys.safari=s[1]: 阅读全文

posted @ 2011-06-01 09:57 wuye1200 阅读(173) 评论(0) 推荐(0)

导航