<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="css/rss.xslt"?>
<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>I'm Emment - Javascript</title><link>http://www.imemment.com/</link><description>欢迎地球外的生命光临，一起维护宇宙和平 - </description><generator>RainbowSoft Studio Z-Blog 1.8 Spirit Build 80722</generator><language>zh-CN</language><copyright>Copyright www.imemment.com. Some Rights Reserved.</copyright><pubDate>Thu, 09 Sep 2010 09:47:46 +0800</pubDate><item><title>Opera 这个浏览器相对比较烂</title><author>emment@126.com (emment)</author><link>http://www.imemment.com/post/102.html</link><pubDate>Fri, 23 Apr 2010 11:56:53 +0800</pubDate><guid>http://www.imemment.com/post/102.html</guid><description><![CDATA[输入 imemment.com 没反应<br/><br/>Opera 的 fixed 定位有严重的BUG <br/><br/><p class="code"><code>&lt;div&nbsp;style="&nbsp;position:fixed;&nbsp;top:100px;&nbsp;left:20px;&nbsp;width:100px;&nbsp;height:100px;&nbsp;background-color:#006666;"&gt;text&lt;/div&gt;</code></p><br/>这样一个BOX  fixed 定位，放在内容很高可以出现滚动条的页面里<br/>把滚动条拉到中间，刷新，你会发现 BOX 不见了，变成绝对定位了，有时候甚至会刷没了<br/>最近在写一个JS浮动功能，除了ie6  Opera的毛病最多了，IE6 人家是前辈 有问题可以理解<br/>Opera实在不行啊·· 只能发泄一下 没本事就别搞那么多浏览器 ]]></description><category>Javascript</category><comments>http://www.imemment.com/post/102.html#comment</comments><wfw:comment>http://www.imemment.com/</wfw:comment><wfw:commentRss>http://www.imemment.com/feed.asp?cmt=102</wfw:commentRss><trackback:ping>http://www.imemment.com/cmdwxh.asp?act=tb&amp;id=102&amp;key=d6af5ffa</trackback:ping></item><item><title>Safari下一个关于parentNode.removeChild超级诡异的BUG</title><author>emment@126.com (emment)</author><link>http://www.imemment.com/post/101.html</link><pubDate>Wed, 14 Apr 2010 19:49:16 +0800</pubDate><guid>http://www.imemment.com/post/101.html</guid><description><![CDATA[做了一个FLASH，定时10秒后去调用JS 的方法 close<br/><br/><p class="code"><code>function&nbsp;close(){<br/>var&nbsp;p=domObj.parentNode;<br/>p.removeChild(domObj)<br/>}</code></p><br/>就是删除FLASH自身所在的dom父节点。<br/>很奇怪在Safari下面，时间一到执行close方法浏览器就奔溃<br/><br/>直接用JS去运行close方法 却没有任何异常   用FLASH中的点击去调close也没问题<br/>只能用诡异来形容了，因为肯定是底层的原因造成的<br/><br/>无法找到原因，于是我就用了一个办法，见代码<br/><br/><p class="code"><code>function&nbsp;close(){<br/>var&nbsp;p=domObj.parentNode;<br/>//执行权给到JS的时候，让他延时10秒，由JS来removeChild<br/>setTimeout(function(){p.removeChild(domObj);},10);&nbsp;<br/>}</code></p><br/>奔溃问题解决了，考<br/>有知道深层原因的看官请发表意见 谢谢<br/>]]></description><category>Javascript</category><comments>http://www.imemment.com/post/101.html#comment</comments><wfw:comment>http://www.imemment.com/</wfw:comment><wfw:commentRss>http://www.imemment.com/feed.asp?cmt=101</wfw:commentRss><trackback:ping>http://www.imemment.com/cmdwxh.asp?act=tb&amp;id=101&amp;key=e4ff34e0</trackback:ping></item><item><title>js脚本中动态调用外部js库的研究</title><author>emment@126.com (emment)</author><link>http://www.imemment.com/post/98.html</link><pubDate>Wed, 31 Mar 2010 11:45:42 +0800</pubDate><guid>http://www.imemment.com/post/98.html</guid><description><![CDATA[看题目可能不太懂什么意思<br/>最近做一些广告库的代码<br/>给第三方去接入，不可能让人家在网站的head标签中给你插入一段js引用<br/>而我考虑到 以js库的形式能以文件的方式缓存，多次使用的时候，提高下载效率<br/>减少服务器压力。<br/>在脚本中 首先要动态在head中插入一段js库的标签<br/>代码如下<br/><br/><p class="code"><code>(function(){<br/>&nbsp;&nbsp;&nbsp;&nbsp;if(document.getElementById('jsid'))<br/>&nbsp;&nbsp;&nbsp;&nbsp;return;<br/>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;s=document.createElement('script');<br/>&nbsp;&nbsp;&nbsp;&nbsp;s.type='text/javascript';<br/>&nbsp;&nbsp;&nbsp;&nbsp;s.id&nbsp;=&nbsp;'jsid';<br/>&nbsp;&nbsp;&nbsp;&nbsp;s.src='js/test.js';<br/>&nbsp;&nbsp;&nbsp;&nbsp;document.getElementsByTagName('head')[0].appendChild(s);<br/>&nbsp;&nbsp;})();</code></p><br/>其中 test.js 有很多工具方法，被封装在一个对象中，我在接下来的代码中需要调用<br/>问题肯定来了，test.js 什么时候加载完成呢，立刻调用它的方法肯定找不到定义啦<br/><br/>思考： <br/>去监听script标签 加载，产生一个回调方法，去触发后面的代码开始<br/>OK 没问题，但是假如有1个以上的脚本都要用这一个JS库呢？他到底在回调中 运行哪个脚本的初始函数？<br/>初始函数都加进去运行好了！ 但是你怎么就知道所有的脚本都加载完了呢？<br/>也就是说回调运行的初始函数 不一定都能调得到 ，所以这个方法不行<br/>同样考虑ajax去监听加载状态，产生回调同样不行<br/><br/>解决方法：<br/>在test.js 库的最后一行设置一个全局变量，变量名复杂点防止冲突  比如   $value_version_2010 = "2010.03.21";<br/>在你的脚本这样写<br/><br/><p class="code"><code>(function(){<br/>&nbsp;&nbsp;&nbsp;&nbsp;if(typeof&nbsp;$value_version_2010&nbsp;!=&nbsp;"undefined"){<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//你的代码<br/>&nbsp;&nbsp;&nbsp;&nbsp;}else{<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setTimeout(arguments.callee,50);<br/>&nbsp;&nbsp;&nbsp;&nbsp;}<br/>})();</code></p><br/>不断去检查这个变量，不存在就延时50秒 重新执行，一旦有了值，你的代码就可以安全执行了<br/>你可以设置个全局变量记录重新执行的次数，来防止无限执行，当然只要是全局变量 你都要考虑命名安全，尽量复杂点吧<br/><br/>各位看官，不知道在这方面谁还有什么高招，欢迎跟帖<br/>]]></description><category>Javascript</category><comments>http://www.imemment.com/post/98.html#comment</comments><wfw:comment>http://www.imemment.com/</wfw:comment><wfw:commentRss>http://www.imemment.com/feed.asp?cmt=98</wfw:commentRss><trackback:ping>http://www.imemment.com/cmdwxh.asp?act=tb&amp;id=98&amp;key=ccf2b208</trackback:ping></item><item><title>javascript中实现命名空间</title><author>emment@126.com (emment)</author><link>http://www.imemment.com/post/95.html</link><pubDate>Thu, 25 Feb 2010 13:53:20 +0800</pubDate><guid>http://www.imemment.com/post/95.html</guid><description><![CDATA[javascript本身不支持命名空间，但是我们可以模拟它<br/>例如，要创建一个名为 arc90.components 命名空间，我们首先定义一个空对象arc90：<br/><br/><p class="code"><code>arc90&nbsp;=&nbsp;{}</code></p><br/>如果叫做arc90的对象已经存在，我们需要先检查一下，然后创建一个空对象：<br/>]]></description><category>Javascript</category><comments>http://www.imemment.com/post/95.html#comment</comments><wfw:comment>http://www.imemment.com/</wfw:comment><wfw:commentRss>http://www.imemment.com/feed.asp?cmt=95</wfw:commentRss><trackback:ping>http://www.imemment.com/cmdwxh.asp?act=tb&amp;id=95&amp;key=5c2ad7ba</trackback:ping></item><item><title>javascript attachEvent和addEventListener 使用方法</title><author>emment@126.com (emment)</author><link>http://www.imemment.com/post/94.html</link><pubDate>Tue, 23 Feb 2010 15:29:30 +0800</pubDate><guid>http://www.imemment.com/post/94.html</guid><description><![CDATA[javascript attachEvent和addEventListener 使用方法<br/><br/>attachEvent方法，为某一事件附加其它的处理事件。（不支持Mozilla系列）<br/>addEventListener方法 用于 Mozilla系列<br/>举例:<br/>document.getElementById("btn").onclick = method1; <br/>document.getElementById("btn").onclick = method2; <br/>document.getElementById("btn").onclick = method3;<br/>如果这样写,那么将会只有medhot3被执行<br/>写成这样：<br/>var btn1Obj = document.getElementById("btn1"); <br/>//object.attachEvent(event,function); <br/>btn1Obj.attachEvent("onclick",method1); <br/>btn1Obj.attachEvent("onclick",method2); <br/>btn1Obj.attachEvent("onclick",method3);<br/>执行顺序为method3->method2->method1<br/><br/>如果是Mozilla系列，并不支持该方法，需要用到addEventListener<br/>var btn1Obj = document.getElementById("btn1"); <br/>//element.addEventListener(type,listener,useCapture); <br/>btn1Obj.addEventListener("click",method1,false); <br/>btn1Obj.addEventListener("click",method2,false); <br/>btn1Obj.addEventListener("click",method3,false);<br/>执行顺序为method1->method2->method3<br/><br/>使用实例：<br/>1。<br/>var el = EDITFORM_DOCUMENT.body;  <br/>//先取得对象，EDITFORM_DOCUMENT实为一个iframe<br/>if (el.addEventListener){<br/>     el.addEventListener(’’click’’, KindDisableMenu, false); <br/>} else if (el.attachEvent){<br/>     el.attachEvent(’’onclick’’, KindDisableMenu);<br/>}<br/>2。<br/>if (window.addEventListener) {<br/>   window.addEventListener(’’load’’, _uCO, false); <br/>} else if (window.attachEvent) { ]]></description><category>Javascript</category><comments>http://www.imemment.com/post/94.html#comment</comments><wfw:comment>http://www.imemment.com/</wfw:comment><wfw:commentRss>http://www.imemment.com/feed.asp?cmt=94</wfw:commentRss><trackback:ping>http://www.imemment.com/cmdwxh.asp?act=tb&amp;id=94&amp;key=51dee79a</trackback:ping></item><item><title>一些常用的JS 片段代码（写过了老是忘记，所以建个帖子）</title><author>emment@126.com (emment)</author><link>http://www.imemment.com/post/72.html</link><pubDate>Mon, 03 Aug 2009 10:33:24 +0800</pubDate><guid>http://www.imemment.com/post/72.html</guid><description><![CDATA[自动跳转页面代码<br/><p class="code"><code>&lt;script&nbsp;type="text/javascript"&gt;<br/>&nbsp;&nbsp;function&nbsp;gotoUrl(){<br/>&nbsp;&nbsp;&nbsp;&nbsp;window.location.href&nbsp;=&nbsp;"http://www.baidu.com";<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;function&nbsp;getTimer(){<br/>&nbsp;&nbsp;&nbsp;&nbsp;timer&nbsp;=&nbsp;setTimeout("gotoUrl()",&nbsp;1000);<br/>&nbsp;&nbsp;}<br/>&lt;/script&gt;<br/>&lt;body&nbsp;onload="getTimer()"&gt;<br/></code></p><br/>给body插入一段DOM对象<br/><br/>因为IE必须等待body全部加载完成，才能获取body对象，所以不能用 document.body.appendChild(domObject);<br/>代替他用<br/><p class="code"><code>document.body.insertBefore(domObject,&nbsp;document.body.childNodes[0]);</code></p><br/>函数内部执行顺序问题<br/><br/>都知道js是预读所有的function，而不管函数位置在什么地方，再去执行其他的代码  <br/>但是直接量的函数是不会预读的<br/><p class="code"><code>var&nbsp;testFun=function(){}</code></p>还有一个就是函数内部，应该是按顺序读的，内部写function最好全部写在最前面]]></description><category>Javascript</category><comments>http://www.imemment.com/post/72.html#comment</comments><wfw:comment>http://www.imemment.com/</wfw:comment><wfw:commentRss>http://www.imemment.com/feed.asp?cmt=72</wfw:commentRss><trackback:ping>http://www.imemment.com/cmdwxh.asp?act=tb&amp;id=72&amp;key=f5331484</trackback:ping></item></channel></rss>
