坏小仔

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2012年8月22日

摘要: 1 <script type="text/javascript"> 2 function globalEval(data) { 3 data = data.replace(/^\s*|\s*$/g, ""); 4 if (data) { 5 var head = document.getElementsByTagName("head")[0] || 6 document.documentElement, 7 8 script = document.createElement("script"); 9 s 阅读全文
posted @ 2012-08-22 17:17 坏小仔 阅读(141) 评论(0) 推荐(0) 编辑

摘要: Another way that we can cause strings of code to be evaluated, and in this caseasynchronously, is through the user of timers.Normally, as we saw in chapter 8, we’d pass an inline function or a function reference toa timer. This is the recommended usage of the setTimeout() and setInterval()methods, B 阅读全文
posted @ 2012-08-22 17:03 坏小仔 阅读(93) 评论(0) 推荐(0) 编辑

摘要: All functions in JavaScript are an instance of Function.; we learned that back in chapter 3.There we saw how we could create named functions using syntax such as functionname(...){...}, or omit the name to create anonymous functions.However, we can also instantiate functions directly using the Funct 阅读全文
posted @ 2012-08-22 17:00 坏小仔 阅读(105) 评论(0) 推荐(0) 编辑

摘要: The eval() method will return the result of the last expression in the passed code string.For example, if we were to call:eval('3+4;5+6')the result would be 11.It should be noted that anything that isn't a simple variable, primitive, or assignment willactually need to be wrapped in a par 阅读全文
posted @ 2012-08-22 16:57 坏小仔 阅读(154) 评论(0) 推荐(0) 编辑

2012年8月21日

摘要: setTimeout(function() { #1/* Some long block of code... */ #1setTimeout(arguments.callee, 10); #1}, 10); #1setInterval(function() { #2/* Some long block of code... */ #2}, 10); #2#1 Sets up a timeout that reschedules itself#2 Sets up an intervalThe two pieces of code in listing 8.1 may appear to be 阅读全文
posted @ 2012-08-21 17:05 坏小仔 阅读(152) 评论(0) 推荐(0) 编辑

摘要: var pattern = /test/;var pattern = new RegExp("test");i (insensitive), g (global), and m (multi-line) /test/ig new RegExp("test","ig"))? i: makes the regex case insenstive. So /test/i matches not only “test”, but also“Test”, “TEST”, “tEsT”, and so on.? g: matches all in 阅读全文
posted @ 2012-08-21 11:09 坏小仔 阅读(115) 评论(0) 推荐(0) 编辑

2012年7月10日

摘要: function trim(str){ //删除左右两端的空格 return str.replace(/(^\s*)|(\s*$)/g, ""); } function ltrim(str){ //删除左边的空格 return str.replace(/(^\s*)/g,""); } function rtrim(str){ //删除右边的空格 return str.replace(/(\s*$)/g,""); }function trim(str){ return str.replace(/^(\s|\u00A0)+/,'& 阅读全文
posted @ 2012-07-10 15:44 坏小仔 阅读(390) 评论(0) 推荐(0) 编辑