<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://feeds.qzone.qq.com/rss.xsl" version="1.0"?>
<rss version="2.0" xmlns:qz="http://qzone.qq.com">
<channel>
<title><![CDATA[ 宝君]]></title>
<description><![CDATA[3589431]]></description>
<link>http://3589431.qzone.qq.com</link>
<lastBuildDate>Fri, 27 Nov 2009 15:59:17 GMT</lastBuildDate>
<generator>Qzone</generator>
<language>zh-cn</language>
<copyright>Copyright (C), 2005-2008, Tencent Tech. Co., Ltd.</copyright>
<pubDate>Mon, 16 Nov 2009 08:33:40 GMT</pubDate>

<item>
<title><![CDATA[优化PHP代码的40条建议]]></title>
<link>http://3589431.qzone.qq.com/blog/1258360420</link>
<description><![CDATA[40 Tips for optimizing your php Code<br>原文地址：<a href="http://reinholdweber.com/?p=3" target="_blank"><span style="color:#78afd3;line-height:1.8em;">http://reinholdweber.com/?p=3</span><wbr /></a><wbr /><br>英文版权归Reinhold Weber所有，中译文作者yangyang（aka davidkoree）。双语版可用于非商业传播，但须注明英文版作者、版权信息，以及中译文作者。翻译水平有限，请广大PHPer指正。<br>1. If a method can be static, declare it static. Speed improvement is by a factor of 4. 如果一个方法可静态化，就对它做静态声明。速率可提升至4倍。<br>2. echo is faster than print. echo 比 print 快。<br>3. Use echo’s multiple parameters instead of string concatenation. 使用echo的多重参数（译注：指用逗号而不是句点）代替字符串连接。<br>4. Set the maxvalue for your for-loops before and not in the loop. 在执行for循环之前确定最大循环数，不要每循环一次都计算最大值。<br>5. Unset your variables to free memory, especially large arrays. 注销那些不用的变量尤其是大数组，以便释放内存。<br>6. Avoid magic like __get, __set, __autoload 尽量避免使用__get，__set，__autoload。<br>7. require_once() is expensive require_once()代价昂贵。<br>8. Use full paths in includes and requires, less time spent on resolving the OS paths. 在包含文件时使用完整路径，解析操作系统路径所需的时间会更少。<br>9. If you need to find out the time when the script started executing, $_SERVER[’REQUEST_TIME’] is preferred to time() 如果你想知道脚本开始执行（译注：即服务器端收到客户端请求）的时刻，使用$_SERVER[‘REQUEST_TIME’]要好于time()。<br>10. See if you can use strncasecmp, strpbrk and stripos instead of regex. 检查是否能用strncasecmp，strpbrk，stripos函数代替正则表达式完成相同功能。<br>11. str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4. str_replace函数比preg_replace函数快，但strtr函数的效率是str_replace函数的四倍。<br>12. If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, instead of one line of code that accepts arrays as search and replace arguments. 如果一个字符串替换函数，可接受数组或字符作为参数，并且参数长度不太长，那么可以考虑额外写一段替换代码，使得每次传递参数是一个字符，而不是只写一行代码接受数组作为查询和替换的参数。<br>13. It’s better to use select statements than multi if, else if, statements. 使用选择分支语句（译注：即switch case）好于使用多个if，else if语句。<br>14. Error suppression with @ is very slow. 用@屏蔽错误消息的做法非常低效。<br>15. Turn on apache’s mod_deflate 打开apache的mod_deflate模块。<br>16. Close your database connections when you’re done with them. 数据库连接当使用完毕时应关掉。<br>17. $row[’id’] is 7 times faster than $row[id]. $row[‘id’]的效率是$row[id]的7倍。<br>18. Error messages are expensive. 错误消息代价昂贵。<br>19. Do not use functions inside of for loop, such as for ($x=0; $x &lt; count($array); $x) The count() function gets called each time. 尽量不要在for循环中使用函数，比如for ($x=0; $x &lt; count($array); $x)每循环一次都会调用count()函数。<br>20. Incrementing a local variable in a method is the fastest. Nearly the same as calling a local variable in a function. 在方法中递增局部变量，速度是最快的。几乎与在函数中调用局部变量的速度相当。<br>21. Incrementing a global variable is 2 times slow than a local var. 递增一个全局变量要比递增一个局部变量慢2倍。<br>22. Incrementing an object property (eg. $this-&gt;prop++) is 3 times slower than a local variable. 递增一个对象属性（如：$this-&gt;prop++）要比递增一个局部变量慢3倍。<br>23. Incrementing an undefined local variable is 9-10 times slower than a pre-initialized one. 递增一个未预定义的局部变量要比递增一个预定义的局部变量慢9至10倍。<br>24. Just declaring a global variable without using it in a function also slows things down (by about the same amount as incrementing a local var). PHP probably does a check to see if the global exists. 仅定义一个局部变量而没在函数中调用它，同样会减慢速度（其程度相当于递增一个局部变量）。PHP大概会检查看是否存在全局变量。<br>25. Method invocation appears to be independent of the number of methods defined in the class because I added 10 more methods to the test class (before and after the test method) with no change in performance. 方法调用看来与类中定义的方法的数量无关，因为我（在测试方法之前和之后都）添加了10个方法，但性能上没有变化。<br>26. Methods in derived classes run faster than ones defined in the base class. 派生类中的方法运行起来要快于在基类中定义的同样的方法。<br>27. A function call with one parameter and an empty function body takes about the same time as doing 7-8 $localvar++ operations. A similar method call is of course about 15 $localvar++ operations. 调用带有一个参数的空函数，其花费的时间相当于执行7至8次的局部变量递增操作。类似的方法调用所花费的时间接近于15次的局部变量递增操作。<br>28. Surrounding your string by ‘ instead of &quot; will make things interpret a little faster since php looks for variables inside &quot;…&quot; but not inside ‘…’. Of course you can only do this when you don’t need to have variables in the string. 用单引号代替双引号来包含字符串，这样做会更快一些。因为PHP会在双引号包围的字符串中搜寻变量，单引号则不会。当然，只有当你不需要在字符串中包含变量时才可以这么做。<br>29. When echoing strings it’s faster to separate them by comma instead of dot. Note: This only works with echo, which is a function that can take several strings as arguments. 输出多个字符串时，用逗号代替句点来分隔字符串，速度更快。注意：只有echo能这么做，它是一种可以把多个字符串当作参数的“函数”（译注：PHP手册中说echo是语言结构，不是真正的函数，故把函数加上了双引号）。<br>30. A PHP script will be served at least 2-10 times slower than a static HTML page by Apache. Try to use more static HTML pages and fewer scripts. Apache解析一个PHP脚本的时间要比解析一个静态HTML页面慢2至10倍。尽量多用静态HTML页面，少用脚本。<br>31. Your PHP scripts are recompiled every time unless the scripts are cached. Install a PHP caching product to typically increase performance by 25-100% by removing compile times. 除非脚本可以缓存，否则每次调用时都会重新编译一次。引入一套PHP缓存机制通常可以提升25%至100%的性能，以免除编译开销。<br>32. Cache as much as possible. Use memcached - memcached is a high-performance memory object caching system intended to speed up dynamic web applications by alleviating database load. OP code caches are useful so that your script does not have to be compiled on every request. 尽量做缓存，可使用memcached。memcached是一款高性能的内存对象缓存系统，可用来加速动态Web应用程序，减轻数据库负载。对运算码(OP code)的缓存很有用，使得脚本不必为每个请求做重新编译。<br>33. When working with strings and you need to check that the string is either of a certain length you’d understandably would want to use the strlen() function. This function is pretty quick since it’s operation does not perform any calculation but merely return the already known length of a string available in the zval structure (internal C struct used to store variables in PHP). However because strlen() is a function it is still somewhat slow because the function call requires several operations such as lowercase &amp; hashtable lookup followed by the execution of said function. In some instance you can improve the speed of your code by using an isset() trick. 当操作字符串并需要检验其长度是否满足某种要求时，你想当然地会使用strlen()函数。此函数执行起来相当快，因为它不做任何计算，只返回在zval结构（C的内置数据结构，用于存储PHP变量）中存储的已知字符串长度。但是，由于strlen()是函数，多多少少会有些慢，因为函数调用会经过诸多步骤，如字母小写化（译注：指函数名小写化，PHP不区分函数名大小写）、哈希查找，会跟随被调用的函数一起执行。在某些情况下，你可以使用isset()技巧加速执行你的代码。<br>Ex.（举例如下）<br>if (strlen($foo) &lt; 5) { echo &quot;Foo is too short&quot;; }<br>vs.（与下面的技巧做比较）<br>if (!isset($foo{5})) { echo &quot;Foo is too short&quot;; }<br>Calling isset() happens to be faster then strlen() because unlike strlen(), isset() is a language construct and not a function meaning that it’s execution does not require function lookups and lowercase. This means you have virtually no overhead on top of the actual code that determines the string’s length. 调用isset()恰巧比strlen()快，因为与后者不同的是，isset()作为一种语言结构，意味着它的执行不需要函数查找和字母小写化。也就是说，实际上在检验字符串长度的顶层代码中你没有花太多开销。<br>34. When incrementing or decrementing the value of the variable $i++ happens to be a tad slower then ++$i. This is something PHP specific and does not apply to other languages, so don’t go modifying your C or Java code thinking it’ll suddenly become faster, it won’t. ++$i happens to be faster in PHP because instead of 4 opcodes used for $i++ you only need 3. Post incrementation actually causes in the creation of a temporary var that is then incremented. While pre-incrementation increases the original value directly. This is one of the optimization that opcode optimized like Zend’s PHP optimizer. It is still a good idea to keep in mind since not all opcode optimizers perform this optimization and there are plenty of ISPs and servers running without an opcode optimizer. 当执行变量$i的递增或递减时，$i++会比++$i慢一些。这种差异是PHP特有的，并不适用于其他语言，所以请不要修改你的C或Java代码并指望它们能立即变快，没用的。++$i更快是因为它只需要3条指令(opcodes)，$i++则需要4条指令。后置递增实际上会产生一个临时变量，这个临时变量随后被递增。而前置递增直接在原值上递增。这是最优化处理的一种，正如Zend的PHP优化器所作的那样。牢记这个优化处理不失为一个好主意，因为并不是所有的指令优化器都会做同样的优化处理，并且存在大量没有装配指令优化器的互联网服务提供商（ISPs）和服务器。<br>35. Not everything has to be OOP, often it is too much overhead, each method and object call consumes a lot of memory. 并不是事必面向对象(OOP)，面向对象往往开销很大，每个方法和对象调用都会消耗很多内存。<br>36. Do not implement every data structure as a class, arrays are useful, too. 并非要用类实现所有的数据结构，数组也很有用。<br>37. Don’t split methods too much, think, which code you will really re-use. 不要把方法细分得过多，仔细想想你真正打算重用的是哪些代码？<br>38. You can always split the code of a method later, when needed. 当你需要时，你总能把代码分解成方法。<br>39. Make use of the countless predefined functions. 尽量采用大量的PHP内置函数。<br>40. If you have very time consuming functions in your code, consider writing them as C extensions. 如果在代码中存在大量耗时的函数，你可以考虑用C扩展的方式实现它们。<br>41. Profile your code. A profiler shows you, which parts of your code consumes how many time. The Xdebug debugger already contains a profiler. Profiling shows you the bottlenecks in overview. 评估检验(profile)你的代码。检验器会告诉你，代码的哪些部分消耗了多少时间。Xdebug调试器包含了检验程序，评估检验总体上可以显示出代码的瓶颈。<br>42. mod_gzip which is available as an Apache module compresses your data on the fly and can reduce the data to transfer up to 80%. mod_zip可作为Apache模块，用来即时压缩你的数据，并可让数据传输量降低80%。<br>43. Excellent Article （<a href="http://phplens.com/lens/php-book/optimizing-debugging-php.php" target="_blank"><span style="color:#78afd3;line-height:1.8em;">http://phplens.com/lens/php-book/optimizing-debugging-php.php</span><wbr /></a><wbr />）about optimizing php by John Lim 另一篇优化PHP的精彩文章，由John Lim撰写。 <!--v:3.2--> ]]></description>
<category><![CDATA[php]]></category>
<author><![CDATA[3589431@qq.com( 宝君)]]></author>
<comments>http://3589431.qzone.qq.com/blog/1258360420#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Mon, 16 Nov 2009 08:33:40 GMT</pubDate>
<guid>http://3589431.qzone.qq.com/blog/1258360420</guid>
</item>

<item>
<title><![CDATA[面对挫折时用英语灵活应对]]></title>
<link>http://3589431.qzone.qq.com/blog/1258089399</link>
<description><![CDATA[<span style="font-weight:bold"><wbr />1. Hang in there.</span><wbr /><br><span style="font-weight:bold"><wbr />撑下去。</span><wbr /><br>想像有人快要从悬崖上掉下去, 只剩下一只手抓著仅剩的一点的石块, 这时候他最需要的一句话就是 &quot;Hang in there.&quot; 在这里 hang in 就是抓住不要让自己掉下去的意思。用在实际的生活中, 就是鼓励别人要坚持下去, 不要放弃。像有一次电视节目中有个人被枪所射伤, 他的好友就对他说, &quot;Hang in there. I'll call the ambulance.&quot; (撑下去, 我去叫救护车。)<br><span style="font-weight:bold"><wbr />2. Cheer up. You've done a good job.</span><wbr /><br><span style="font-weight:bold"><wbr />高兴点, 你作得很好啊。</span><wbr /><br>Cheer up 也是常用来鼓励人的话, 就是要别人高兴一点, 不要难过 (Don't be sad.) 而 &quot;You've done a good job.&quot; 这句话则几乎己经成为一种固定用法, 每当别人完成一件任务时, 你都可以跟他说, &quot;You've done a good job.&quot; 或是简单地说, &quot;Good job.&quot; 或是 &quot;Well done.&quot;<br><span style="font-weight:bold"><wbr />3. You are very supportive.</span><wbr /><br><span style="font-weight:bold"><wbr />你很支持我。</span><wbr /><br>支持在中文里是个动词, 所以这句话很多人会说成 &quot;You support me a lot.&quot; 这样的讲法也没错, 但 support somebody 在英文里常有在金钱上支持某人作某件事的意思。 例如 &quot;My parents support me to go to the college.&quot; (我父母供我上大学.)因此老美常用 supportive 来表示一个人对一个人的支持。 <br>例如一些访谈的节目中就常可以听到这样的话, &quot;My husband is very supportive.&quot; (我的丈夫对我十分支持。) 或是要感谢别人对你的支持时, 你也可以说, &quot;You are very supportive.&quot;<br>从这个例子我们可以学到, 从中文转换成英文时, 其词性也常常会跟著改变, 如果没有注意到这点的话, 常常就会生成所谓的中式英文。(Chinese English)<br><span style="font-weight:bold"><wbr />4. I'll survive.</span><wbr /><br><span style="font-weight:bold"><wbr />我会活下去。</span><wbr /><br>当自己遇到了十分艰难的情况时, 就可以说这句, &quot;I'll survive.&quot; 来激励自己一下。 意思是不管情况再怎么艰难, 你都会活下去。 <br>例如和心爱的女友分手了. 别人可能会问问你, &quot;Are you all right?&quot; 你就可以说, &quot;I'll survive. Thanks&quot; (多谢你, 我会活下去的。)<br>另外类似的讲法叫 &quot;I'll get over it.&quot; 同样也是指自己会度过难关的意思。 <br>例如当你输了一场重要的比赛, 这时就可以安慰自己说, &quot;I'll get over it.&quot;<br><span style="font-weight:bold"><wbr />5. It's not the end of the world.</span><wbr /><br><span style="font-weight:bold"><wbr />这不是世界末日。</span><wbr /><br>当别人极度难过的时候, 就需要给他们一些强而有力的鼓舞, 英文里也有很多成语都可以派得上用场。我自己最常听老美说的就是, &quot;It's not the end of the world.&quot;, 日子还很长, 地球不会因为你的失败而停止转动, 所以你要继续过你的生活。<br>类似的讲法, 你也可以鼓励人家, &quot;Tomorrow is another day.&quot; 明天又是全新的一天, 你也不必太过沮丧。(这是电影乱世佳人的最后一句台词, 因此这句话也成了一句大家耳熟能详的话。)<br><span style="font-weight:bold"><wbr />6. Face it.</span><wbr /><br><span style="font-weight:bold"><wbr />面对现实吧！</span><wbr /><br>&quot;Face it.&quot; 跟 &quot;Deal with it.&quot; 都是口语中非常常见的用法, 指的是去面对眼前的这个状况。<br>例如有人说他很想追某个名花有主的女孩, 你就可以劝他, &quot;Face it. She is dating someone else.&quot; (面对现实吧。她已经有交往的对象了。) 再举个例子, 比方说没钱花了,但你的狐群狗党们还要你出去吃喝玩乐。这时你就可以说, &quot;Deal with it. I have no money now.&quot; (面对现实吧! 我已经没钱了。)<br>如果是极度困难的状况, 则还可以用 face the music 这个片语来加强语气, 这可不是听音乐的意思喔! 而是指面对困难的状况, 例如, &quot;We have to face the music; your father is a nut case.&quot; (我们必须面对现实, 你的父亲是个疯子。)<br><span style="font-weight:bold"><wbr />7. They treat me like crap.</span><wbr /><br><span style="font-weight:bold"><wbr />他们待我像废物一样。</span><wbr /><br>Crap这个字指的是废物(也就是便便的意思啦!), 是个不雅的字眼, 不该在正式场合使用。但是有时用到恰到好处, 却有画龙点睛之效。例如当别人对你非常不好, 简直就完全无视于你的存在。这时你就可以去跟别人哭诉。&quot;They treat me like crap.&quot; <br><span style="font-weight:bold"><wbr />8. I am a big fat zero.</span><wbr /><br><span style="font-weight:bold"><wbr />我什么都不是。</span><wbr /><br>Big fat zero 是一个很特殊的用法, 通常是指一个人觉得自己什么都不是, 像是个废物一样。像有一次我看电视, 剧中的女主角她男朋友说什么也不肯娶她。她就很自卑地说了一句, &quot;I am a big fat zero.&quot;<br><span style="font-weight:bold"><wbr />9. Calm down.</span><wbr /><br><span style="font-weight:bold"><wbr />冷静一下。</span><wbr /><br>每当有人太激动时你就可以安抚他说, &quot;Calm down.&quot; 或是 &quot;Chill out.&quot; 还有人也把 &quot;Calm down.&quot; 说成 &quot;Stay cool.&quot; 同样都是要别人保持冷静的意思，这些也都是常听到的口语用法。像是有一次我开车去游泳, 结果居然把车钥匙放在泳裤口袋里就噗通一声跳下水了, 等到我发现时为时以晚。车钥匙上 security system 的小摇控器已经泡水不能用了, 我简直就快疯了。这时一个好心的老美就跑来跟我说, &quot;Calm down. Let's work this out together&quot; (冷静些, 让我们一起来解决这个问题。)<br><span style="font-weight:bold"><wbr />10. I'll back you up no matter what's happening.</span><wbr /><br><span style="font-weight:bold"><wbr />不论发生什么事情, 我都会支持你。</span><wbr /><br>Back someone up 指的就是支持别人。这个字也可以当名词用, 例如, &quot;I will be your backup.&quot; (我会作你的后盾。) 当我们看到别人想作一件事情却犹豫不决时, 就可以跟他说, &quot;Just go for it. I'll back you up.&quot; (放手去做吧, 我会支持你的。） <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[3589431@qq.com( 宝君)]]></author>
<comments>http://3589431.qzone.qq.com/blog/1258089399#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Fri, 13 Nov 2009 05:16:39 GMT</pubDate>
<guid>http://3589431.qzone.qq.com/blog/1258089399</guid>
</item>

<item>
<title><![CDATA[2009年最令人无语语录]]></title>
<link>http://3589431.qzone.qq.com/blog/1257848001</link>
<description><![CDATA[1、心里有座坟，葬着未亡人<br>3、要么忍，要么残忍<br>4、旋转木马是这世上最残酷的游戏，彼此追逐，却永远隔着可悲的距离<br>5、难免埋怨时间的手，把相爱写成相爱过<br>6、等待你的关心，等到我关上了心<br>7、我爱你时，你说什么就是什么。 我不爱你时，你说你是什么。<br>8、爱.直至成伤<br>9、如果你注定不能给予我期待的回应。那么就保持在安全距离之外吧<br>10、你给我滚，马不停蹄的滚……<br>11、最是夜深人静时，思念才变得如此放肆<br>12、回忆是一座桥，却是通往寂寞的牢<br>13、离开后，别说祝我幸福，你有什么资格祝我幸福。<br>14、老板，先来两斤真爱，拿回去喂狗！<br>15、都说从此天涯陌路～什么是天涯？转身，背向你，此刻已是天涯……<br>16、你永远也看不到我最寂寞时候的样子，因为只有你不在我身边的时候，我才最寂寞。<br>17、不要和地球人一般见识~~~ <br>19、幸福是个比较级，要有东西垫底才感觉得到<br>20、有些事，我们明知道是错的，也要去坚持，因为不甘心；有些人，我们明知道是爱的，也要去放弃，因为没结局；有时候，我们明知道没路了，却还在前行，因为习惯了。<br>21、时间是用来流浪的，身躯是用来相爱的，生命是用来遗忘的，而灵魂，是用来歌唱的。<br>22、通常愿意留下来跟你争吵的人，才是真正爱你的人！<br>23、老鼠一发威，大家都是病猫。<br>24、读10年语文，不如聊半年QQ。<br>25、摇啊摇，摇到奈何桥。<br>26、给点阳光我就腐烂。<br>27、拍脑袋决策，拍胸脯保证，拍屁股走人。<br>28、我们走得太快，灵魂都跟不上了……<br>29、老子不打你，你不知道我文武双全。<br>30、人生就像一个茶几，虽然不大，但是充满了杯具。。。 <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[3589431@qq.com( 宝君)]]></author>
<comments>http://3589431.qzone.qq.com/blog/1257848001#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Tue, 10 Nov 2009 10:13:21 GMT</pubDate>
<guid>http://3589431.qzone.qq.com/blog/1257848001</guid>
</item>

<item>
<title><![CDATA[三步计算php程序执行时间]]></title>
<link>http://3589431.qzone.qq.com/blog/1250141453</link>
<description><![CDATA[&lt;?php <br>$stime=microtime(true); //获取程序开始执行的时间 <br><br>echo &quot;hello world&quot;;         //你执行的代码 <br><br>$etime=microtime(true);//获取程序执行结束的时间 <br>$total=$etime-$stime;   //计算差值 <br>echo &quot;&lt;br /&gt;{$total} times&quot;; <br><br>?&gt; <br>假如执行时间很小,比如0.0000001等,它会使用科学计数法. <br>比如 4.6014785766602E-005 times 并非4.6(注意它后面有个E-005),而是将小数点向前移动5位,真实的值应该是0.000046... <!--v:3.2--> ]]></description>
<category><![CDATA[ruby入门教程]]></category>
<author><![CDATA[3589431@qq.com( 宝君)]]></author>
<comments>http://3589431.qzone.qq.com/blog/1250141453#comment</comments>
<qz:effect>134742016</qz:effect>
<pubDate>Thu, 13 Aug 2009 05:30:53 GMT</pubDate>
<guid>http://3589431.qzone.qq.com/blog/1250141453</guid>
</item>

<item>
<title><![CDATA[div 屏幕垂直居中对齐]]></title>
<link>http://3589431.qzone.qq.com/blog/1246938065</link>
<description><![CDATA[<span style="color:#ff0000;line-height:1.8em;">div 屏幕垂直居中对齐 （纯CSS代码控制源代码）：</span><wbr /> <br><span style="color:#330000;line-height:1.8em;">&lt;div style=&quot;width:500px; height:100px; background:#999; position:absolute; left:50%;top:50%; margin-top:-50px; margin-left:-250px; font-size:12px&quot;&gt; <br>  &lt;p&gt;此层为：width:500px; height:80px&lt;/p&gt; <br>  &lt;p&gt;定位关键是：position:absolute; left:50%;top:50%; margin-top: - height/2 ; margin-left: - width/2 &lt;/p&gt; <br>  &lt;p&gt;效果是：横向居中，纵向居中&lt;/p&gt; <br>&lt;/div&gt;</span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[HTML]]></category>
<author><![CDATA[3589431@qq.com( 宝君)]]></author>
<comments>http://3589431.qzone.qq.com/blog/1246938065#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Tue, 07 Jul 2009 03:41:05 GMT</pubDate>
<guid>http://3589431.qzone.qq.com/blog/1246938065</guid>
</item>

<item>
<title><![CDATA[Linux下启动/关闭/重启Mysql]]></title>
<link>http://3589431.qzone.qq.com/blog/1245813430</link>
<description><![CDATA[命令:/etc/init.d/mysql   start|stop|restart|reload|force-reload <!--v:3.2--> ]]></description>
<category><![CDATA[linux]]></category>
<author><![CDATA[3589431@qq.com( 宝君)]]></author>
<comments>http://3589431.qzone.qq.com/blog/1245813430#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Wed, 24 Jun 2009 03:17:10 GMT</pubDate>
<guid>http://3589431.qzone.qq.com/blog/1245813430</guid>
</item>

<item>
<title><![CDATA[使用distinct在数据库中查询多条不重复记录值的解决办法]]></title>
<link>http://3589431.qzone.qq.com/blog/1242629284</link>
<description><![CDATA[完整语句:select *, count(distinct 重复的字段名) from 表名 group by 重复字段名 <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[3589431@qq.com( 宝君)]]></author>
<comments>http://3589431.qzone.qq.com/blog/1242629284#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Mon, 18 May 2009 06:48:04 GMT</pubDate>
<guid>http://3589431.qzone.qq.com/blog/1242629284</guid>
</item>

<item>
<title><![CDATA[我注册了城市达人！]]></title>
<link>http://3589431.qzone.qq.com/blog/1241660443</link>
<description><![CDATA[ 最近周围生活和工作的朋友中，经常有人说起自己是达人，经常参加什么 <a href="http://city.qzone.qq.com/meet/#PSN=rz" target="_blank">聚会</a><wbr /> ，认识了不少同城朋友，甚至还找到了同行业的朋友。<br><br> 周末在家有空，我去看了一下 <a href="http://city.qzone.qq.com/#PSN=rz" target="_blank">城市达人社区</a><wbr /> ，确实发现不少与我爱好相同的朋友，而且让我感觉温馨的是，他们都有真实照片。<br><br> 我这人最讲信用，以诚相待，为了以后大家更方便沟通，今天我也注册了达人。<br><br> 我比较喜欢影视，所以我选择为 <a href="http://city.qzone.qq.com/html/user/guest.htm#uin=3589431&amp;PSN=rz" target="_blank">音乐达人</a><wbr /> 。希望交流 <a href="http://city.qzone.qq.com/html/user/guest.htm#uin=3589431&amp;PSN=rz" target="_blank">音乐</a><wbr /> 的朋友可以给我 <a href="http://city.qzone.qq.com/html/user/guest.htm#uin=3589431&amp;PSN=rz" target="_blank">留言</a><wbr /> ，当然我也希望更多达人彼此相互认识，朋友多了路好走啊！ <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[3589431@qq.com( 宝君)]]></author>
<comments>http://3589431.qzone.qq.com/blog/1241660443#comment</comments>
<qz:effect>134217728</qz:effect>
<pubDate>Thu, 07 May 2009 01:40:43 GMT</pubDate>
<guid>http://3589431.qzone.qq.com/blog/1241660443</guid>
</item>

<item>
<title><![CDATA[undefined method `cache_template_extensions=' for ActionView::Base:Class错误解决办法]]></title>
<link>http://3589431.qzone.qq.com/blog/1240325103</link>
<description><![CDATA[Remove “cache_template_extensions = false” from config/environments/development.rb<br>就OK啦 <!--v:3.2--> ]]></description>
<category><![CDATA[rails]]></category>
<author><![CDATA[3589431@qq.com( 宝君)]]></author>
<comments>http://3589431.qzone.qq.com/blog/1240325103#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Tue, 21 Apr 2009 14:45:03 GMT</pubDate>
<guid>http://3589431.qzone.qq.com/blog/1240325103</guid>
</item>

<item>
<title><![CDATA[js技巧收集(200多个)]]></title>
<link>http://3589431.qzone.qq.com/blog/1240233619</link>
<description><![CDATA[1、〖前进〗命令的实现<br>[格式]history.go(1) 或 history.forward()<br>[说明]浏览器打开后一个页面。<br>[举例]在&lt;body&gt;&lt;/body&gt;之间加入：<br>&lt;a href=&quot;###&quot; onclick=history.go(1)&gt;前进&lt;/a&gt;<br>或加入:<br>&lt;a href=&quot;###&quot; onclick=history.forward()&gt;前进&lt;/a&gt;<br>2、〖后退〗命令的实现<br>[格式]:history.go(-1) 或 history.back()<br>[说明]浏览器返回上一个已浏览的页面。<br>[举例]在&lt;body&gt;&lt;/body&gt;之间加入：<br>&lt;a href=&quot;###&quot; onclick=history.go(-1)&gt;后退&lt;/a&gt;<br>或加入:<br>&lt;a href=&quot;###&quot; onclick=history.back()&gt;后退&lt;/a&gt;<br>3、〖刷新〗命令的实现<br>[格式]:document.reload() 或 history.go(0)<br>[说明]浏览器重新打开本页。<br>[举例]在&lt;body&gt;&lt;/body&gt;之间加入：<br>&lt;a href=&quot;###&quot; onclick=location.reload()&gt;刷新&lt;/a&gt;<br>或加入:<br>&lt;a href=&quot;###&quot; onclick=history.go(0)&gt;刷新&lt;/a&gt;<br>185.其它命令的实现<br>〖定时关闭本窗口〗命令的实现<br>[格式]:settimeout(window.close(),关闭的时间)<br>[说明]将关闭本窗口。<br>[举例]在&lt;body&gt;&lt;/body&gt;之间加入：<br>&lt;a href=&quot;###&quot; onclick=settimeout(window.close(),3000)&gt;3秒关闭本窗口&lt;/a&gt;<br><br>【附】为了方便读者，下面将列出所有实例代码，你可以把它们放到一个html文件中，然后预览效果。<br>&lt;a href=&quot;###&quot; onclick=document.execCommand(&quot;open&quot;)&gt;打开&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=location.replace(&quot;view-source:&quot;+location)&gt;使用 记事本编辑&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=document.execCommand(&quot;saveAs&quot;)&gt;另存为&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=document.execCommand(&quot;print&quot;)&gt;打印&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=window.close();return false)&gt;关闭本窗口&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=document.execCommand(&quot;selectAll&quot;)&gt;全选&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=location.reload()&gt;刷新&lt;/a&gt; &lt;a href=&quot;###&quot; onclick=history.go(0)&gt;刷新&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=location.replace(&quot;view-source:&quot;+location)&gt;查看源文件&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=window.open(document.location,&quot;url&quot;,&quot;fullscreen&quot;)&gt;全屏显示&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;javascript:window.external.AddFavorite('http://homepage.yesky.com', '天极网页陶吧')&quot;&gt;添加到收藏<br>夹&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=window.external.showBrowserUI(&quot;OrganizeFavorites&quot;,null)&gt;整理收藏夹&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=window.external.showBrowserUI(&quot;PrivacySettings&quot;,null)&gt;internet选项&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=history.go(1)&gt;前进1&lt;/a&gt;　&lt;a href=&quot;###&quot; onclick=history.forward()&gt;前进2&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=history.go(-1)&gt;后退1&lt;/a&gt;　&lt;a href=&quot;###&quot; onclick=history.back()&gt;后退2&lt;/a&gt;&lt;br&gt;<br>&lt;a href=&quot;###&quot; onclick=settimeout(window.close(),3000)&gt;3秒关闭本窗口&lt;/a&gt;&lt;br&gt;<br><br>186.给DHTML中的标签添加一个新的属性，可以随意加<br>&lt;BODY onload=&quot;alert(a1.epass)&quot;&gt;<br>&lt;input type=text name=&quot;a1&quot; epass=&quot;zhongguo&quot;&gt;<br>&lt;/BODY&gt;//<br><br>187.xmlhttp技术<br>&lt;BODY&gt; 此方法是通过XMLHTTP对象从服务器获取XML文档，示例如下。 <br>&lt;input type=button value=&quot;加载XML文档&quot; onclick=&quot;getData('data.xml')&quot; &gt; <br>&lt;script language=&quot;JavaScript&quot; &gt; <br>function getDatal(url){ <br>var xmlhttp = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);//创建XMLHTTPRequest对象 <br>xmlhttp.open(&quot;GET&quot;,url,false,&quot;&quot;,&quot;&quot;);//使用HTTP GET初始化HTTP请求 <br>xmlhttp.send(&quot;&quot;);//发送HTTP请求并获取HTTP响应 <br>return xmlhttp.responseXML;//获取XML文档 <br>} <br>&lt;/script &gt; <br>&lt;/BODY&gt;//<br>188.服务器端通过request.getReader()获得传入的字符串<br>189.在java中使用正则表达式<br>java.util.regex.Pattern p =<br>java.util.regex.Pattern.compile(<a href="http://blog.csdn.net/lxs5i5j/archive/2007/01/22/%22%20%20d+%7C.%20%20d+%7C%20%20d+.%20%20d*%7C(E%7C%20%20d+E%7C.%20%20d+E%7C%20%20d+.%20%20d*E)((%20%20+%7C-)%20%20d%7C%20%20d)%20%20d" target="_blank">http://blog.csdn.net/lxs5i5j/archive/2007/01/22/&quot;\\d+|.\\d+|\\d+.\\d*|(E|\\d+E|.\\d+E|\\d+.\\d*E)((\\+|-)\\d|\\d)\\d</a><wbr />*&quot;);<br>java.util.regex.Matcher m = p.matcher(&quot;12.E+3&quot;);<br>boolean result = m.matches();//<br><br>190.给下拉框分组<br>&lt;SELECT&gt;<br>&lt;OPTGROUP LABEL=&quot;碱性金属&quot;&gt;<br>&lt;OPTION&gt;锂 (Li)&lt;/OPTION&gt;<br>&lt;OPTION&gt;纳 (Na)&lt;/OPTION&gt;<br>&lt;OPTION&gt;钾 (K)&lt;/OPTION&gt;<br>&lt;/OPTGROUP&gt;<br>&lt;OPTGROUP LABEL=&quot;卤素&quot;&gt;<br>&lt;OPTION&gt;氟 (F)&lt;/OPTION&gt;<br>&lt;OPTION&gt;氯 (Cl)&lt;/OPTION&gt;<br>&lt;OPTION&gt;溴 (Br)&lt;/OPTION&gt;<br>&lt;/OPTGROUP&gt;<br>&lt;/SELECT&gt;//<br>191.加注音<br>&lt;RUBY&gt;<br>基准文本<br>&lt;RT&gt;注音文本<br>&lt;/RUBY&gt;//<br><br>192.加删除线<br>&lt;S&gt;此文本将带删除线显示。&lt;/S&gt;//<br>193.取frame中的event事件<br>document.frames(&quot;workspace&quot;).event.keyCode//<br>194.是弹出方法的定义<br>String.prototype.trim=function()<br>{<br>return this.replace(/(^\s*)|(\s*$)/g, &quot;&quot;);<br>}<br>alert(&quot;   &quot;.trim)//<br>195.防止网页被包含<br>if (window != window.top)<br>top.location.href = location.href;//<br><br>196.让网页一直在frame里面<br>if(window==window.top)<br>{<br>document.body.innerHTML=&quot;&lt;center&gt;&lt;h1&gt;请通过正常方式访问本页面！&lt;/h1&gt;&lt;/center&gt;&quot;;<br>//window.close();<br>}//<br><br>197.加为首页<br>&lt;SCRIPT&gt;<br>function fnSet(){<br>oHomePage.setHomePage(location.href);<br>event.returnValue = false;<br>}<br>&lt;/SCRIPT&gt;<br>&lt;IE:HOMEPAGE ID=&quot;oHomePage&quot; style=&quot;behavior:url(#default#homepage)&quot;/&gt;//<br><br>198.xml数据岛操作<br>&lt;HTML&gt;<br>   &lt;HEAD&gt;&lt;Title&gt;HTML中的数据岛中的记录集&lt;/Title&gt;&lt;/HEAD&gt;<br>   &lt;body bkcolor=#EEEEEE text=blue bgcolor=&quot;#00FFFF&quot;&gt;<br>   &lt;Table align=center width=&quot;100%&quot;&gt;&lt;TR&gt;&lt;TD align=&quot;center&quot;&gt;<br>   &lt;h5&gt;&lt;b&gt;&lt;font size=&quot;4&quot; color=&quot;#FF0000&quot;&gt;HTML中的XML数据岛记录编辑与添加     &lt;/font&gt;&lt;/b&gt;&lt;/h5&gt;<br>   &lt;/TD&gt;&lt;/TR&gt;&lt;/Table&gt;<br>   &lt;HR&gt;<br>   酒店名称：&lt;input type=text datasrc=http://blog.csdn.net/lxs5i5j/archive/2007/01/22/1489880.aspx#theXMLisland DataFLD=NAME size=&quot;76&quot;&gt;&lt;BR&gt;<br>   地址：&lt;input type=text datasrc=http://blog.csdn.net/lxs5i5j/archive/2007/01/22/1489880.aspx#theXMLisland DataFLD=Address size=&quot;76&quot;&gt;&lt;BR&gt;<br>   主页：&lt;input type=text datasrc=http://blog.csdn.net/lxs5i5j/archive/2007/01/22/1489880.aspx#theXMLisland DataFLD=HomePage size=&quot;76&quot;&gt;&lt;BR&gt;<br>   电子邮件：&lt;input type=text datasrc=http://blog.csdn.net/lxs5i5j/archive/2007/01/22/1489880.aspx#theXMLisland DataFLD=E-Mail size=&quot;76&quot;&gt;&lt;BR&gt;<br>   电话：&lt;input type=text datasrc=http://blog.csdn.net/lxs5i5j/archive/2007/01/22/1489880.aspx#theXMLisland DataFLD=TelePhone size=&quot;76&quot;&gt;&lt;BR&gt;<br>   级别：&lt;input type=text datasrc=http://blog.csdn.net/lxs5i5j/archive/2007/01/22/1489880.aspx#theXMLisland DataFLD=Grade size=&quot;76&quot;&gt;&lt;HR&gt;<br>   &lt;input id=&quot;first&quot; TYPE=button value=&quot;&lt;&lt;　第一条记录&quot;      onclick=&quot;theXMLisland.recordset.moveFirst()&quot;&gt;<br>   &lt;input id=&quot;prev&quot; TYPE=button value=&quot;&lt;上一条记录&quot;    onclick=&quot;theXMLisland.recordset.movePrevious()&quot;&gt;  <br>   &lt;input id=&quot;next&quot; TYPE=button value=&quot;下一条记录&gt;&quot; onclick=&quot;theXMLisland.recordset.moveNext()&quot;&gt;  <br>   &lt;input id=&quot;last&quot; TYPE=button value=&quot;最后一条记录&gt;&gt;&quot; onclick=&quot;theXMLisland.recordset.moveLast()&quot;&gt;&amp;nbsp;  <br>   &lt;input id=&quot;Add&quot; TYPE=button value=&quot;添加新记录&quot; onclick=&quot;theXMLisland.recordset.addNew()&quot;&gt;<br>   &lt;XML ID=&quot;theXMLisland&quot;&gt;<br>   &lt;HotelList&gt;<br>   &lt;Hotel&gt;<br>   &lt;Name&gt;四海大酒店&lt;/Name&gt;<br>   &lt;Address&gt;海魂路1号&lt;/Address&gt;<br>   &lt;HomePage&gt;www.sihaohotel.com.cn&lt;/HomePage&gt; <br>   &lt;E-Mail&gt;master@sihaohotel.com.cn&lt;/E-Mail&gt;<br>   &lt;TelePhone&gt;(0989)8888888&lt;/TelePhone&gt; <br>   &lt;Grade&gt;五星级&lt;/Grade&gt;<br>   &lt;/Hotel&gt;<br>   &lt;Hotel&gt;<br>   &lt;Name&gt;五湖宾馆&lt;/Name&gt;<br>   &lt;Address&gt;东平路99号&lt;/Address&gt;<br>   &lt;HomePage&gt;www.wuhu.com.cn&lt;/HomePage&gt; <br>   &lt;E-Mail&gt;web@wuhu.com.cn&lt;/E-Mail&gt;<br>   &lt;TelePhone&gt;(0979)1111666&lt;/TelePhone&gt; <br>   &lt;Grade&gt;四星级&lt;/Grade&gt;<br>   &lt;/Hotel&gt;<br>   &lt;Hotel&gt;<br>   &lt;Name&gt;“大沙漠”宾馆&lt;/Name&gt;<br>   &lt;Address&gt;留香路168号&lt;/Address&gt;<br>   &lt;HomePage&gt;www.dashamohotel.com.cn&lt;/HomePage&gt; <br>   &lt;E-Mail&gt;master@dashamohotel.com.cn&lt;/E-Mail&gt;<br>   &lt;TelePhone&gt;(0989)87878788&lt;/TelePhone&gt; <br>   &lt;Grade&gt;五星级&lt;/Grade&gt;<br>   &lt;/Hotel&gt;<br>   &lt;Hotel&gt;<br>   &lt;Name&gt;“画眉鸟”大酒店&lt;/Name&gt;<br>   &lt;Address&gt;血海飘香路2号&lt;/Address&gt;<br>   &lt;HomePage&gt;www.throstlehotel.com.cn&lt;/HomePage&gt; <br>   &lt;E-Mail&gt;chuliuxiang@throstlehotel.com.cn&lt;/E-Mail&gt;<br>   &lt;TelePhone&gt;(099)9886666&lt;/TelePhone&gt; <br>   &lt;Grade&gt;五星级&lt;/Grade&gt;<br>   &lt;/Hotel&gt;<br>   &lt;/HotelList&gt; <br>   &lt;/XML&gt;<br>   &lt;/body&gt;  <br>   &lt;/HTML&gt; //xml数据岛中添加记录<br><br>-------------------------------<br>   The following list is a sample of the properties and methods that you use to access nodes in an XML<br>document.<br>Property/     Method Description <br>XMLDocument Returns a reference to the XML Document Object Model (DOM) exposed by the object.<br>documentElement   Returns the document root of the XML document. <br>childNodes     Returns a node list containing the children of a node (if any). <br>item      Accesses individual nodes within the list through an index. Index values are zero-based, so<br>item(0) returns the first child node. <br>text      Returns the text content of the node.<br>The following code shows an HTML page containing an XML data island. The data island is contained within<br>the &lt;XML&gt; element.<br>&lt;HTML&gt;<br>   &lt;HEAD&gt;<br>     &lt;TITLE&gt;HTML with XML Data Island&lt;/TITLE&gt;<br>   &lt;/HEAD&gt;<br>   &lt;BODY&gt;<br>     &lt;P&gt;Within this document is an XML data island.&lt;/P&gt;<br>     &lt;XML ID=&quot;resortXML&quot;&gt;<br>       &lt;resorts&gt;<br>         &lt;resort code='1'&gt;Adventure Works&lt;/resort&gt;<br>         &lt;resort&gt;Alpine Ski House&lt;/resort&gt;<br>       &lt;/resorts&gt;<br>     &lt;/XML&gt;<br>   &lt;/BODY&gt;<br>&lt;/HTML&gt;<br>For an example, you can cut and paste this sample line of code:<br>resortXML.XMLDocument.documentElement.childNodes.item(1).text//读取页面上的XML数据岛中的数据<br>resortXML.documentElement.childNodes.item(0).getAttribute(&quot;code&quot;)//读取页面上的XML数据岛中的数据<br>resortXML.documentElement.childNodes[0].getAttribute(&quot;code&quot;)//读取页面上的XML数据岛中的数据<br>199.模式窗口<br>父窗口<br>var url=&quot;aaa.jsp&quot;;<br>var<br>data=showModalDialog(url,null,&quot;dialogHeight:400px;dialogHeight:600px;center:yes;help:No;status:no;resizab<br>le:Yes;edge:sunken&quot;);<br>if(data)<br>alert(data.value);<br><br>子窗口<br>var data=new Object();<br>data.value1=&quot;china&quot;;<br>window.returnValue=data;<br>window.close();<br><br>200.动态设置事件，带参数<br>&lt;INPUT TYPE=&quot;text&quot; NAME=&quot;a1&quot;&gt;<br>&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;<br>&lt;!--<br>function hah(para)<br>{<br>alert(para)<br>}<br>a1.onclick=function()<br>{<br>hah('canshu ')<br>}<br>//a1.attachEvent(&quot;onclick&quot;,function(){hah('参数')});<br>//--&gt;<br>&lt;/SCRIPT&gt;//<br><br>201.将url转化为16进制形式<br>var ret = '';<br>for(var i=0; i &lt; str.length; i++)<br>{<br>   var ch = str.charAt(i);<br>   var code = str.charCodeAt(i);<br>   if(code &lt; 128 &amp;&amp; ch != '[' &amp;&amp; ch != '\'' &amp;&amp; ch != '=')<br>   {<br>    ret += ch;<br>   }<br>   else <br>   {<br>    ret += &quot;[&quot; + code.toString(16) + &quot;]&quot;;<br>   }<br>}<br>return ret;//<br>202.打开新的窗口并将新打开的窗口设置为活动窗口<br>var newWin=window.open(&quot;xxxx&quot;);<br>newWin.focus();//<br><br>203.容错脚本<br>JS中遇到脚本错误时不做任何操作:window.onerror = doNothing; <br>指定错误句柄的语法为:window.onerror = handleError<br>function handleError(message, URI, line)<br>{// 提示用户，该页可能不能正确回应<br>return true; // 这将终止默认信息<br>}//在页面出错时进行操作<br>204.JS中的窗口重定向:<br>window.navigate(<a href="http://blog.csdn.net/lxs5i5j/archive/2007/01/22/%22http://www.sina.com.cn%22);//" target="_blank">http://blog.csdn.net/lxs5i5j/archive/2007/01/22/&quot;http://www.sina.com.cn&quot;);//</a><wbr /><br>205.防止链接文字折行<br>document.body.noWrap=true;//<br>206.判断字符是否匹配.<br>string.match(regExpression)//<br>207.<br>href=&quot;javascript:document.Form.Name.value='test';void(0);&quot;//不能用onClick=&quot;javacript:document.Form.Name.v<br>alue='test';return false;&quot;<br>当使用inline方式添加事件处理脚本事，有一个被包装成匿名函数的过程，也就是说<br>onClick=&quot;javacript:document.Form.Name.value='test';return false;&quot;被包装成了：<br>functoin anonymous()<br>{<br>     document.Form.Name.value='test';return false;<br>}<br>做为A的成员函数onclick。<br>而href=&quot;javascript:document.Form.Name.value='test';void(0);&quot;相当于执行全局语句，这时如果使用return语句会<br>报告在函数外使用return语句的错误。<br><br>208.进行页面放大<br>&lt;P onmouseover=&quot;this.style.zoom='200%'&quot; onmouseout=&quot;this.style.zoom='normal'&quot;&gt;<br>sdsdsdsdsdsdsdsds<br>&lt;/p&gt;//<br>209.放置在页面的最右边<br>&lt;input type=&quot;text&quot; value='bu2'   style=&quot;float:right&quot;&gt;//<br>210.通过style来控制隔行显示不同颜色<br>&lt;style&gt;<br>tr{<br>bgcolor:expression(this.bgColor=((this.rowIndex)%2==0 )? 'white' : 'yellow');<br>}<br>&lt;/style&gt;<br>&lt;table id=&quot;oTable&quot; width=&quot;100&quot; border=&quot;1&quot; style=&quot;border-collapse:collapse;&quot;&gt;<br>&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;<br>&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;<br>&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;<br>&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;<br>&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;<br>&lt;/table&gt;//<br>211.全屏最大化<br>newwindow=window.open(&quot;&quot;,&quot;&quot;,&quot;scrollbars&quot;)<br>if (document.all)<br>{<br>newwindow.moveTo(0,0)<br>newwindow.resizeTo(screen.width,screen.height)<br>}//<br>212.根据名字解析xml中的节点值<br>var XMLDoc=new ActiveXObject(&quot;MSXML&quot;);<br>XMLDoc.url=&quot;d:/abc.xml&quot;;<br>aRoot=XMLDoc.root;<br>a1.innerText=aRoot.children.item(&quot;name&quot;).text;//<br><br>213.在页面上解析xml的值<br><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/5996c682-3472-4b03-9fb0-1e08" target="_blank">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/5996c682-3472-4b03-9fb0-1e08</a><wbr /><br>fcccdf35.asp<br>//<br>214.看一个字符串里面有多少个回车符，返回值是一个数组<br>var s=value.match(/\n/g);if(s)if(s.length==9){alert('10行了');return false;}//<br>215.获得asc码<br>var s='aa';<br>alert(s.charCodeAt(1))//<br><br>216.文字居右对齐<br>&lt;input type=&quot;text&quot; value=&quot;123&quot; style=&quot;text-align:right&quot;&gt;//<br>217.判断一个方法是否存在<br>function pageCallback(response){<br>alert(response);<br>}<br>if(pageCallback)<br>alert(1)//<br><br>218.判断一个变量是否定义<br>if(typeof(a)==&quot;undefined&quot;)<br>{<br>alert()<br>}//<br><br>219.javascript执行本机的可执行程序,需设置为可信或者降低IE安全级别<br>&lt;script&gt;<br>function exec (command) {<br>     window.oldOnError = window.onerror;<br>     window._command = command;<br>     window.onerror = function (err) {<br>       if (err.indexOf('utomation') != -1) {<br>         alert('命令已经被用户禁止！'); <br>         return true;<br>       }<br>       else return false;<br>     };<br>     var wsh = new ActiveXObject('WScript.Shell');<br>     if (wsh)<br>       wsh.Run(command);<br>     window.onerror = window.oldOnError;<br>   }<br>&lt;/script&gt;<br>调用方式<br>&lt;a href=&quot;javascript:&quot; onclick=&quot;exec('D:/test.bat')&quot;&gt;测试&lt;/a&gt;//<br><br>220.弹出新页面，关闭旧页面，不弹出提示框<br>var w=screen.availWidth-10;<br>    var h=screen.availHeight-10;<br>    var swin=window.open(&quot;/mc/mc/message_management.jsp&quot;,<br>&quot;BGSMbest&quot;,&quot;scrollbars=yes,status,location=0,menubar=0,toolbar=0,resizable=no,top=0,left=0,height=&quot;+h+&quot;,w<br>idth=&quot;+w);<br>    window.opener=null;<br>    window.close();//<br>221.能输入的下拉框<br>&lt;span&gt;<br>&lt;input name=&quot;Department1&quot; id=&quot;Department1&quot; style=&quot; border-right:0;width:130&quot; autocomplete=&quot;off&quot;&gt;<br>&lt;span style=&quot;width:150;overflow:hidden&quot;&gt;<br>&lt;select   style=&quot;width:150;margin-left:-130&quot; onChange=&quot;Department1.value=value&quot;&gt; <br>&lt;option value=&quot;&quot;&gt;&lt;/option&gt;<br>&lt;option value=&quot;asdfasfadf&quot;&gt;asdfasfadf&lt;/option&gt;<br>&lt;option value=&quot;546546&quot;&gt;546546&lt;/option&gt;&lt;/select&gt; //<br><br>222.在方法中定义全局变量<br>function globalVar (script) {<br>         eval(script);//all navigators<br>   //window.execScript(script); //for ie only <br>}<br>globalVar('window.haha = &quot;../system&quot;;');<br>alert(haha);//在方法中定义全局变量，其中的haha就是全局变量了<br>223.显示一个对象的全部的属性和属性的值<br>var a=new Object();<br>a.name='a1';<br>a.***='mail'<br>for(var p in a)<br>{<br>alert(p+&quot;=&quot;+a[p])<br>}//<br><br>224.16进制转换成10进制<br>var n = parseInt(&quot;2AE&quot;,16);//这里将16进制的 2AE 转成 10 进制数，得到 n 的值是 686<br><br>225.复制粘贴<br>&lt;BODY&gt;<br>&lt;input type=&quot;file&quot; name='a1'&gt;&lt;input type=&quot;button&quot; value='复制粘贴' onclick=&quot;haha()&quot;&gt;&lt;div id=&quot;aa&quot;&gt;&lt;/div&gt;<br>&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;<br>&lt;!--<br>function haha()<br>{<br>clipboardData.setData(&quot;Text&quot;,a1.value);<br>aa.innerText=clipboardData.getData(&quot;Text&quot;);<br>}<br>//--&gt;<br>&lt;/SCRIPT&gt;<br>&lt;/BODY&gt;//<br>226.获得对象类型<br>switch (object.constructor){<br>    case Date:<br>    ...<br>    case Number:<br>    ...<br>    case String:<br>    ...<br>    case MyObject:<br>    ...<br>    default: <br>    ...<br>}//<br><br>227.图片加载失败时重新加载图片<br>&lt;img src=http://blog.csdn.net/lxs5i5j/archive/2007/01/22/&quot;<a href="http://www.aspxclub.com/UploadFile/Material/1/1283.gif" target="_blank">http://www.aspxclub.com/UploadFile/Material/1/1283.gif</a><wbr />&quot; onerror=&quot;this.src='http://www.aspxclub.com/UploadFile/Material/1/1283.gif'&quot;&gt;//<br><br>228.<br>//font_effect.htc<br>&lt;PUBLIC:ATTACH EVENT=&quot;onmouseover&quot; ONEVENT=&quot;glowit()&quot; /&gt; <br>&lt;PUBLIC:ATTACH EVENT=&quot;onmouseout&quot; ONEVENT=&quot;noglow()&quot; /&gt; <br>&lt;SCRIPT LANGUAGE=&quot;JScript&quot;&gt; <br>//定义一个保存字体颜色的变量 <br>var color;<br>function glowit() <br>{ <br>color=element.style.backgroundColor;<br>element.style.backgroundColor='white'<br>} <br>function noglow() <br>{ <br>   element.style.backgroundColor=color<br>} <br>&lt;/SCRIPT&gt;<br>//abc.css<br>tr{behavior:url(font_effect.htc);}<br>229.可以通过css和htc改变表格的颜色,仅IE支持<br>//xxx.html<br>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;abc.css&quot;&gt;<br>&lt;TABLE border='1'   id=&quot;a1&quot;&gt;<br>&lt;TR style=&quot;background-color:red&quot;&gt;<br>&lt;TD&gt;1&lt;/TD&gt;<br>&lt;TD&gt;2&lt;/TD&gt;<br>&lt;TD&gt;3&lt;/TD&gt;<br>&lt;/TR&gt;<br>&lt;TR style=&quot;background-color:yellow&quot;&gt;<br>&lt;TD&gt;4&lt;/TD&gt;<br>&lt;TD&gt;5&lt;/TD&gt;<br>&lt;TD&gt;6&lt;/TD&gt;<br>&lt;/TR&gt;<br>&lt;/TABLE&gt;//<br>230.在页面上画点<br>function a(x,y,color)<br>{<br>document.write(&quot;&lt;img border='0' style='position: absolute; left: &quot;+(x+20)+&quot;; top:<br>&quot;+(y+20)+&quot;;background-color: &quot;+color+&quot;' width=1 height=1&gt;&quot;)<br>}//<br>231.自动关闭网页<br>&lt;script LANGUAGE=&quot;javascript&quot;&gt;<br>&lt;!--<br>setTimeout('window.close();', 10000); //60秒后关闭<br>// --&gt;<br>&lt;/script&gt;<br>&lt;p align=&quot;center&quot;&gt;本页10秒后自动关闭,请注意刷新页面&lt;/p&gt; <!--v:3.2--> ]]></description>
<category><![CDATA[javascript]]></category>
<author><![CDATA[3589431@qq.com( 宝君)]]></author>
<comments>http://3589431.qzone.qq.com/blog/1240233619#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Mon, 20 Apr 2009 13:20:19 GMT</pubDate>
<guid>http://3589431.qzone.qq.com/blog/1240233619</guid>
</item>

</channel>
</rss>

