|
|
|
|
|
|
jQuery验证控件jquery.validate.js使用说明+中文API
摘要:官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validationjQuery plugin: Validation 使用说明转载自:http://blog.sina.com.cn/s/blog_608475eb0100h3h1.ht...
阅读全文
Bootstrap
摘要:1.http://v3.bootcss.com/getting-started/2.http://blog.dandyweng.com/2013/07/how-my-website-was-created/
阅读全文
<meta http-equiv="X-UA-Compatible" content="IE=edge" />详解
摘要:X-UA-Compatible是针对IE8新加的一个设置,对于IE8之外的浏览器是不识别的,这个区别与content="IE=7"在无论页面是否包含指令,都像是使用了 Windows Internet Explorer 7的标准模式。而content="IE=EmulateIE7"模式遵循指令。对于多数网站来说,它是首选的兼容性模式。 为了避免制作出的页面在IE8下面出现错误,建议直接将IE8使用IE7进行渲染。也就是直接在页面的header的meta标签中加入如下代码:Html代码(即如上meta加在其它meta之前)如下所示:Html代码...2.选
阅读全文
js好文章
摘要:http://dmitrysoshnikov.com/ecmascript/javascript-the-core/
阅读全文
CommonJs
摘要:关于CommonJs,http://raychase.iteye.com/blog/1463617,http://arstechnica.com/business/2009/12/commonjs-effort-sets-javascript-on-path-for-world-domination/官网,http://wiki.commonjs.org/wiki/CommonJS
阅读全文
N皇后问题求解
摘要:用js递归了个算法: // queenNum 为皇后个数, showResult为function(arr){}函数指针 function queen(queenNum, showResult){ var arr = (function(){ var arr = new Array(queenNum); for(var i=0; i<arr.length; i++){ arr[...
阅读全文
How JavaScript Timers Work
摘要:At a fundamental level it’s important to understand how JavaScript timers work. Often times they behave unintuitively because of the single thread which they are in. Let’s start by examining the three functions to which we have access that can construct and manipulate timers.var id = setTimeout(fn,
阅读全文
YSLOW法则中,为什么yahoo推荐用GET代替POST?
摘要:背景:上上周五,公司前端工程师培训,提到前端优化的一些技巧,当然不能少了yahoo yslow的优化法则。其中有这么一条“Use GET for AJAX Requests”,这些法则从最开始的14条,到现在的35条,一直都时刻关注的。可这么一条的原因我却一点都不清楚。在提问的环节里,我对yahoo WEB前端优化法则推荐AJAX中,使用GET代替POST的原因有疑问,便请教前端工程师。我们的工程师说GET的话,浏览器发送一个包,POST会发两个等等。我对这个解释仍带有疑问,甚至怀疑。培训结束后,我随便搜索了一下,并没有得到理想的结果,可能很少人对Yahoo这么有权威的组织提出的优化法则产生怀
阅读全文
window.location获取地址栏不同部分
摘要:有一个需求,需要获取域名部分,但是域名不确定,本地测试时可能是一个ip地址,上线后可能是一个域名,最开始是想通过window.location.href获取,然后进行正则匹配找到前面的地址。经同事提醒才想到window.location可以获取地址栏不同部分,找资料总结如下:我们可以用javascript获得其中的各个部分1, window.location.href整个URl字符串(在浏览器中就是完整的地址栏)本例返回值: http://www.k68.org:80/design/index.html#good2,window.location.protocolURL 的协议部分本例返回值:
阅读全文
Google JavaScript 编码规范指南
摘要:http://alloyteam.github.com/JX/doc/specification/google-javascript.xml
阅读全文
http://developer.yahoo.com/performance/rules.html
摘要:Minimize HTTP Requeststag: content80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, Flash, etc. Reducing the number of components in turn reduces the number of HTTP requests required
阅读全文
The Flyweight Pattern in Javascript
摘要:Flyweight Pattern,中文可译作享元模式。它的核心是分离对象的:内在属性和外部属性,然后共享内在属性,组装外在属性。看一个汽车的例子:/*Carclass,un-optimized.*/varCar=function(make,model,year,owner,tag,renewDate){this.make=make;this.model=model;this.year=year;this.owner=owner;this.tag=tag;this.renewDate=renewDate;};Car.prototype={getMake:function(){returnt..
阅读全文
The Facade Pattern in Javascript
摘要:这里拿给DOM元素设置样式的case来演绎在js中怎么使用Facade Pattern。 先看菜鸟的做法:varelement1=document.getElementById('foo');element1.style.color='red';varelement2=document.getElementById('bar');element2.style.color='red';varelement3=document.getElementById('baz');element3.style.color=
阅读全文
The Decorator Pattern in Javascript
摘要:还是拿自行车车店的例子,当自行车车店针对不同品牌不同车型的车可以自由定制一些东西时怎么办? 比如,顾客想给某种型号的车加一个照面灯。再比如,它们想给车刷个拉风的漆。 如果使用继承,那子类就成千上万了。 这个时候,就可以用到Decorator模式了:/*TheBicycleinterface.*/varBicycle=newInterface("Bicycle",["assemble","wash","ride","repair","getPrice"]);/*AcmeComf
阅读全文
Composite in Javascript
摘要:本文从简的演示利用Composite Pattern来动态创建form,它支持保存和还原上次输入的数据。 第一步,定义接口:varComposite=newInterface("Composite",["add","remove","getChild"]);varFormItem=newInterface("FormItem",["save","restore","getElement"]);你懂的,这里是基于single respon
阅读全文
Bridge Pattern in Javascript
摘要:一个比较简洁的例子:functiongetBeerById(e){ varid=this.id;asyncRequest('GET','beer.uri?id='+id,function(resp){console.log('RequestedBeer:'+resp.responseText);});}addEvent(element,'click',getBeerById);这里可以看到,它其实就是为DOM元素的click绑定一个方法,在这个方法里做一个异步请求,然后当请求成功后,log出response结果。 问题在于getB
阅读全文
Javascript中Factory的应用
摘要:这里拿Pro Javascript Design Pattern中的例子作为case。假如一家自行车店销售各种自行车:/*TheBicycleinterface.*/varBicycle=newInterface("Bicycle",["assemble","wash","ride","repair"]);/*Speedsterclass.*/varSpeedster=function(){}Speedster.prototype={assemble:function(){console.log
阅读全文
Javascript中chaining的实现
摘要:如果你了解Jquery,你一定为它的chaining的便利而折服。而它的原理,其实也很简单,不过是每个方法都返回this对象而已。如下:(function($){function_$(elements){this._elements=[];for(vari=0;i<elements.length;i++){if(typeof(elements[i])=="string"){this._elements.push(document.getElementById(elements[i]));}else{this._elements.push(elements[i]);}}
阅读全文
Javascript中singleton的实现
摘要:最好的实现:varlangzi=window.langzi||{};langzi.singleton=window.langzi.singleton||(function(){varinstance=null;varconstructor=function(){return{id:1,name:"test",getMessage:function(){console.log("id:"+this.id+",name:"+this.name);}};};return{getInstance:function(){if(instance=
阅读全文
Javascript中怎么实现继承?
摘要:传统的继承:varPerson=function(name){ this.name=name||"defaultname";if(typeofPerson._initialized=="undefined"){Person.prototype.getName=function(){returnthis.name;};Person._initialized=true;}};varAuthor=function(name,books){Person.call(this,name);this.books=books||[];/*if(typeofAuthor.
阅读全文
|
|