代码改变世界

随笔分类 -  javascript

js 四舍五入

2016-09-12 21:14 by 蜡笔小旧, 220 阅读, 收藏, 编辑
摘要: 举例excel: ROUND 会四舍五入的;ROUNDDOWN 取小数点后两位数据,不管进位问题;ROUNDUP 取小数点后两位数据,只要有第三位小数都会进位的。关键看你取数的要求 在js如果要求roundup可以使用accounting.js库 (0.615).toFixed(2); // "0. 阅读全文

ko trick

2016-04-30 14:38 by 蜡笔小旧, 196 阅读, 收藏, 编辑
摘要: (1)let a = ko.observable(‘A’)绑定到select,如果下拉列表中找不到'A', 变量a会赋值成undefined. 要解决此问题可以使用绑定valueAllowUnset (2)<div data-bind='abcd'> abcd绑定找不到不会报错 (3)compone 阅读全文

jquery getJSON IE8 cache

2012-09-18 11:31 by 蜡笔小旧, 703 阅读, 收藏, 编辑
摘要: 今天用firefox调试了个统计数据代码没问题,用IE8跑发现取的数据不对,原以为是ExtJs的缓存问题,结果发现是IE缓存的问题。解决办法有两种:(1)服务端(未测试asp.net mvc):public class NoCacheAttribute : ActionFilterAttribute{ public override void OnActionExecuted(ActionExecutedContext context) { context.HttpContext.Response.Cache.SetCacheability(HttpCacheabil... 阅读全文

IE,你是想整人吗?

2012-06-14 19:28 by 蜡笔小旧, 1386 阅读, 收藏, 编辑
摘要: 今天发现网站的某个页面性能奇慢无比,用firebug,fiddler发现莫名其妙的自动调用了当前Controller的 Index action.或IE会自动访问当前Controller的Index action.以上测试环境在IE8。Firefox,Chorme下未出现。记得上次老赵也提过,空路径... 阅读全文

js路径

2011-05-27 11:47 by 蜡笔小旧, 304 阅读, 收藏, 编辑
摘要: 结论:html文件外部引入javascript时,javascript的当前路径是html的当前路径,而不是js文件的当前路径。css不同用的是当前路径。 阅读全文

ajax post submit

2010-12-29 15:56 by 蜡笔小旧, 184 阅读, 收藏, 编辑
摘要: [代码] 阅读全文

JavaScript_Funny ParseInt

2010-03-13 22:52 by 蜡笔小旧, 171 阅读, 收藏, 编辑
摘要: [代码]为什么会这样子?看看parseInt这个函数:parseInt(string, radix)ParameterDescriptionstringRequired. The string to be parsedradixOptional. A number (from 2 to 36) that represents the numeral system to be usedIf the ... 阅读全文

javascript css selector engine-mini

2009-09-21 23:38 by 蜡笔小旧, 654 阅读, 收藏, 编辑
摘要: Javascript类库圈最近似乎活跃。类库、插件层出不穷。今天看到一则selector engine的新闻。介绍一款新的seletor engine - mini(好像是车吧,名如其J,很小很强大)。其他3款车(1)Sizzle(这个知道,jQuery中的selector),(2)Peppy(从没听过)(3)Sly(还是没听过)。4者数据分析上来看,mini快很多,也小得多。一起来看看他支持一些... 阅读全文

good tools 调试好帮手

2009-04-28 17:15 by 蜡笔小旧, 187 阅读, 收藏, 编辑
摘要: 可以抛弃window.alert()了 Blackbird url:http://www.gscottolson.com/blackbirdjs/ a 界面显示以后按[F2]. 阅读全文

js variable undefined

2009-04-28 15:59 by 蜡笔小旧, 258 阅读, 收藏, 编辑
摘要: //asdfasdfasdf未定义 (1) if(asdfasdfasdf){ alert(1); } 结果:IE报错,asdfasdfasdf未定义,try 捕捉不了。 (2) if(typeof asdfasdfasdf){ alert(1); } 结果:输出1 (3) if(typeof asdfasdfasdf == undefined){ alert(... 阅读全文

String

2009-04-27 18:27 by 蜡笔小旧, 132 阅读, 收藏, 编辑
摘要: 阅读全文

my pretty code

2009-04-16 21:30 by 蜡笔小旧, 172 阅读, 收藏, 编辑
摘要: function discountcardchange(cardSelectControlName,cardSelectChangeValue, cardInputControlName) { /// ///span show/hidden ///2009-04-15 /// /// "sltdiscountcard" / "null" /"sp... 阅读全文

document.getElementById IE bug

2009-04-15 14:58 by 蜡笔小旧, 239 阅读, 收藏, 编辑
摘要: document.getElementById('xxx') 在ie下会去读控件属性name 的值。 阅读全文

《JavaScript DOM编程艺术》-附录(dom方法和属性)

2009-04-10 00:53 by 蜡笔小旧, 252 阅读, 收藏, 编辑
摘要: 本附录内容: (1)创建节点: reference = document.createElement(element) reference = document.createTextNode(text) (2)复制节点: reference = node.cloneNode(deep) (3)插入节点 reference = element.appe... 阅读全文

【translate】JavaScript: The Definitive Guide, 5th Edition - (1)

2009-02-19 22:46 by 蜡笔小旧, 277 阅读, 收藏, 编辑
摘要: Section 1.1. What Is JavaScript? JavaScript is the subject of a fair bit of misinformation and confusion. Before proceeding any further, it is important to debunk two common and persistent myths abou... 阅读全文

【translate】JavaScript: The Definitive Guide, 5th Edition - (0)

2009-02-18 21:36 by 蜡笔小旧, 385 阅读, 收藏, 编辑
摘要: Chapter 1. Introduction to JavaScript 2009-02-19 22:00 JavaScript is an interpreted programming language with object-oriented (OO) capabilities. Syntactically, the core JavaScript language resembles ... 阅读全文
点击右上角即可分享
微信分享提示