﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-asfman-文章分类-Ext</title><link>http://www.cnitblog.com/asfman/category/6631.html</link><description>有些事，我们明知道是错的，也要去坚持，因为不甘心；有些人，我们明知道是爱的，也要去放弃，因为没结局；有时候，我们明知道没路了，却还在前行，因为习惯了。</description><language>zh-cn</language><lastBuildDate>Mon, 26 Sep 2011 13:39:51 GMT</lastBuildDate><pubDate>Mon, 26 Sep 2011 13:39:51 GMT</pubDate><ttl>60</ttl><item><title>关于泄漏</title><link>http://www.cnitblog.com/asfman/articles/37683.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Fri, 14 Dec 2007 00:54:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/37683.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/37683.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/37683.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/37683.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/37683.html</trackback:ping><description><![CDATA[<p>经ie7测试 <br>function myButton()<br>{<br>&nbsp;&nbsp;&nbsp; var container=document.createElement("button");<br>&nbsp;&nbsp;&nbsp; /*container.style......*/<br>&nbsp;&nbsp;&nbsp; var text=document.createElement("button");<br>&nbsp;&nbsp;&nbsp; /*text.style......text.innerText......*/</p>
<p>&nbsp;&nbsp;&nbsp; text.onclick=EventBuilder(container);<br>&nbsp;&nbsp;&nbsp; //在这里无论是上面这种写法还是直接写function(){}结果占用内存都一样<br>&nbsp;&nbsp;&nbsp; //只有直接引用外部函数如text.onclick=EventBuilder才能释放button对象,减少内存<br>&nbsp;&nbsp;&nbsp; document.body.appendChild(container);<br>&nbsp;&nbsp;&nbsp; document.body.appendChild(text);<br>&nbsp;&nbsp;&nbsp; //如果onmouseover中我没有用到container 当然可以用 text=null container=null来打破循环引用<br>&nbsp;&nbsp;&nbsp; //经测试用null打不破循环<br>} </p>
<p>function EventBuilder(container)<br>{<br>&nbsp;&nbsp;&nbsp; return function(e)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(container)//这里container可访问<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text=this;//用this访问自身<br>&nbsp;&nbsp;&nbsp; }<br>} <br>for(var i =0;i&lt;5000;i++)<br>myButton()<br>//conclusion<br>闭包使返回的内部函数持有私有变量，所以此私有变量持有的dom对象不能被回收。<br>（被回收的条件：1。 没有context 2。没有被引用 ）<br>不内部写function。把内部变量传递给外部函数闭包返回不能解决问题。<br>所以唯一的方法是直接引用外部函数，如text.onclick = outFunc;</p>
<img src ="http://www.cnitblog.com/asfman/aggbug/37683.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2007-12-14 08:54 <a href="http://www.cnitblog.com/asfman/articles/37683.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>FireBug 控制台函数说明 </title><link>http://www.cnitblog.com/asfman/articles/37408.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Thu, 06 Dec 2007 07:57:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/37408.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/37408.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/37408.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/37408.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/37408.html</trackback:ping><description><![CDATA[<h2>FireBug 控制台函数说明</h2>
<div class=t_msgfont id=postmessage_2416><a href="http://www.nirvanastudio.org/javascript/firebug-%e6%8e%a7%e5%88%b6%e5%8f%b0%e5%87%bd%e6%95%b0%e8%af%b4%e6%98%8e.html" target=_blank>FireBug 控制台函数说明</a>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; Posted by <a href="http://www.nirvanastudio.org/author/Nicholas" target=_blank>Nicholas Ding</a> on 九月 20th, 2006<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 原文地址：<a href="http://www.joehewitt.com/software/firebug/docs.php" target=_blank>http://www.joehewitt.com/software/firebug/docs.php</a><br><a href="http://www.nirvanastudio.org/javascript/firebug-%E6%8E%A7%E5%88%B6%E5%8F%B0%E5%87%BD%E6%95%B0%E8%AF%B4%E6%98%8E.html" target=_blank>http://www.nirvanastudio.org/<span class=t_tag onclick=tagshow(event) href="tag.php?name=java">java</span>script/firebug-%E6%8E%A7%E5%88%B6%E5%8F%B0%E5%87%BD%E6%95%B0%E8%AF%B4%E6%98%8E.html</a><br>
<blockquote><a href="http://www.joehewitt.com/software/firebug/" target=_blank>FireBug</a> 是一个非常实用的<span class=t_tag onclick=tagshow(event) href="tag.php?name=JavaScript">JavaScript</span>以及DOM查看调试工具，是 Firefox 的一个插件。使用 FireBug 调试 AJAX 应用非常方便，终于可以告别 alert 时代了！</blockquote>Console Logging 函数FireBug 为所有 Web 页面提供了一个 console 对象。这个对象有以下函数：<br><br>Logging 基础<br><strong>console.log("message" [,objects])</strong> - 将一个字符串打印到控制台。字符串可以包含任何&#8220;String Formatting&#8221;小节描述的模式。字符串后面的对象应该用来取代之前字符串中的模式。（译者注：大家用过C里面 printf 吧，效果基本是一样的。）<br>Logging 等级通常根据不同的等级来区分Logging的严重程度是很有帮助的。FireBug 提供了4个等级。为了达到视觉分离的效果，这些函数与 log 不同的地方就是它们在被调用的时候会自动包含一个指向代码行数的链接。<br><strong>console.debug("message" [,objects])</strong> - 记录一个 debug 消息。<br><strong>console.info("message" [,objects])</strong> - 记录一个信息.<br><strong>console.warn("message" [,objects])</strong> - 记录一个警告.<br><strong>console.error("message" [,objects])</strong> - 记录一个错误.<br><br>断言断言是一条确保代码规则的非常好的途径。console 对象包含了一系列各种类型的断言函数，并且允许你编写自己的断言函数。<br><strong>console.assert(a, "message" [,objects])</strong> - Asserts that an a is true.<br><strong>console.assertEquals(a, b, "message" [,objects])</strong> - Asserts that a is equal to b.<br><strong>console.assertNotEquals(a, b, "message" [,objects])</strong> - Asserts that a is not equal to b.<br><strong>console.assertGreater(a, b, "message" [,objects])</strong> - Asserts that a is greater than b.<br><strong>console.assertNotGreater(a, b, "message" [,objects])</strong> - Asserts that a is not greater than b.<br><strong>console.assertLess(a, b, "message" [,objects])</strong> - Asserts that a is less than b.<br><strong>console.assertNotLess(a, b, "message" [,objects])</strong> - Asserts that a is not less than b.<br><strong>console.assertContains(a, b, "message" [,objects])</strong> - Asserts that a is in the array b.<br><strong>console.assertNotContains(a, b, "message" [,objects])</strong> - Asserts that a is not in the array b.<br><strong>console.assertTrue(a, "message" [,objects])</strong> - Asserts that a is equal to true.<br><strong>console.assertFalse(a, "message" [,objects])</strong> - Asserts that a is equal to <span class=t_tag onclick=tagshow(event) href="tag.php?name=false">false</span>.<br><strong>console.assertNull(a, "message" [,objects])</strong> - Asserts that a is equal to null.<br><strong>console.assertNotNull(a, "message" [,objects])</strong> - Asserts that a is not equal to null.<br><strong>console.assertUndefined(a, "message" [,objects])</strong> - Asserts that a is equal to undefined.<br><strong>console.assertNotUndefined(a, "message" [,objects])</strong> - Asserts that a is not equal to undefined.<br><strong>console.assertInstanceOf(a, b, "message" [,objects])</strong> - Asserts that a is an instance of type b.<br><strong>console.assertNotInstanceOf(a, b, "message" [,objects])</strong> - Asserts that a is not an instance of type b.<br><strong>console.assertTypeOf(a, b, "message" [,objects])</strong> - Asserts that the type of a is equal to the string b.<br><strong>console.assertNotTypeOf(a, b, "message" [,objects])</strong> - Asserts that the type of a is not equal to the string b.<br><br>测量（Measurement）下面的一些函数可以让你方便的测量你的一些代码。<br><strong>console.trace()</strong> - 记录执行点的堆栈信息。<br><strong>console.time("name")</strong> - 根据 name 创建一个唯一的计时器。<br><strong>console.timeEnd("name")</strong> - 根据 name 停止计时器，并且记录消耗的时间，以毫秒为单位。<br><strong>console.count("name")</strong> - 记录该行代码执行的次数。<br><br>字符串格式化所有 console 的 logging 函数都可以通过以下模式格式化字符串：<br><strong>%s</strong> - 将对象格式化为字符串。<br><strong>%d, %i, %l, %f</strong> - 将对象格式化为数字。<br><strong>%o</strong> - 将对象格式化成一个指向 inspector 的超链接。<br><strong>%1.o, %2.0, etc..</strong> - 将对象格式化成包含自己属性的可交互的表格。<br><strong>%.o</strong> - 将对象格式化成具有自身属性的一个数组。<br><strong>%x</strong> - 将对象格式化成一个可交互的 XML 树形结构。<br><strong>%1.x, %2.x, etc..</strong> - 将对象格式化成一个可交互的 XML 数型结构，并且展开 <em>n</em> 层节点。<br>如果你需要一个真实的 % 符号，你可以通过一个转移符号就像这样 "\%"。<br>命令行函数内建的命令行函数可以通过以下命令行使用：<br><strong>$("id")</strong> - document.getElementById() 的简写。（译者注：跟 prototype.js 学来的吧？）<br><strong>$$("css")</strong> - 返回一个符合 CSS 选择器的元素数组。<br><strong>$x("xpath")</strong> - 返回一个符合 XPath 选择器的元素数组。<br><strong>$0</strong> - 返回最近被检查（inspected）的对象。<br><strong>$1</strong> - 返回最近被检查（inspected）的下一个对象。<br><strong>$n(5)</strong> - 返回最近被检查的第n个对象。<br><strong>inspect(object)</strong> - 将对象显示在 Inspector 中。<br><strong>dir(object)</strong> - 返回一个对象的属性名数组。（译者注：跟 Python 学的？）<br><strong>clear()</strong> - 清除控制台信息。</div>
<img src ="http://www.cnitblog.com/asfman/aggbug/37408.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2007-12-06 15:57 <a href="http://www.cnitblog.com/asfman/articles/37408.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>列表项的右键菜单实现</title><link>http://www.cnitblog.com/asfman/articles/37389.html</link><dc:creator>汪杰</dc:creator><author>汪杰</author><pubDate>Thu, 06 Dec 2007 00:33:00 GMT</pubDate><guid>http://www.cnitblog.com/asfman/articles/37389.html</guid><wfw:comment>http://www.cnitblog.com/asfman/comments/37389.html</wfw:comment><comments>http://www.cnitblog.com/asfman/articles/37389.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/asfman/comments/commentRss/37389.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/asfman/services/trackbacks/37389.html</trackback:ping><description><![CDATA[<div class=t_msgfont id=postmessage_2682>列表项的右键菜单实现<br><br>html:<br>&lt;div id="rightClickCont"&gt;&lt;/div&gt;<br><br>js:<br>//右键菜单<br><span class=t_tag onclick=tagshow(event) href="tag.php?name=%3Chighlight%3Egri"><highlight>gri</span>d</highlight>.addListener('rowcont<span class=t_tag onclick=tagshow(event) href="tag.php?name=ext">ext</span>menu', rightClickFn);//右键菜单代码关键部分<br>var rightClick = new Ext.menu.Menu({<br>&nbsp; &nbsp; id:'rightClickCont',<br>&nbsp; &nbsp; items: [<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;//id: 'rMenu1',<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;//handler: rMenu1Fn,<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;text: '右键菜单1'<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;},<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;//id: 'rMenu2',<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;//handler: rMenu2Fn,<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;text: '右键菜单2'<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br>&nbsp; &nbsp; ]<br>});<br>//右键菜单代码关键部分<br>function rightClickFn(grid,rowindex,e){<br>&nbsp; &nbsp; e.preventDefault();<br>&nbsp; &nbsp; rightClick.showAt(e.getXY());<br>}<br><br><br><br>02、单击列表项实现<br><br>grid.addListener('rowclick', rowclickFn);<br>function rowclickFn(grid,rowindex,e){<br>&nbsp; &nbsp; alert('单击 '+ rowindex);<br>}<br><br><br><br>03、双击列表项实现<br><br>grid.addListener('rowdblclick', rowdblclickFn);<br>function rowdblclickFn(grid,rowindex,e){<br>&nbsp; &nbsp; alert('双击 '+ rowindex);<br>}</div>
<img src ="http://www.cnitblog.com/asfman/aggbug/37389.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/asfman/" target="_blank">汪杰</a> 2007-12-06 08:33 <a href="http://www.cnitblog.com/asfman/articles/37389.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>