<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>程序如此灵动！ &#187; javascript</title>
	<atom:link href="http://newsn.net/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://newsn.net</link>
	<description>苏南的网络日记本本  O(∩_∩)O  哈哈~</description>
	<lastBuildDate>Mon, 13 Jul 2009 02:59:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>强制修改wordpress的正文链接为新开窗口打开</title>
		<link>http://newsn.net/20090629/725.html</link>
		<comments>http://newsn.net/20090629/725.html#comments</comments>
		<pubDate>Mon, 29 Jun 2009 00:14:44 +0000</pubDate>
		<dc:creator>苏南</dc:creator>
				<category><![CDATA[IT.IT]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://newsn.net/20090629/725.html</guid>
		<description><![CDATA[WordPress的正文做链接的时候，默认是本页打开的，用livewriter写博客的时候也是默认本页打开。当然据说这样更符合国际化标准，但是好像对中国人的习惯新开页面得习惯有点水土不服。而且外带我很懒的去给所有的链接去增加target=’_blank’属性。今天说的是，批量修改这些页面链接，强制新开页面。
 
     一、写在前面     本文主要使用了一个函数，getElementsByClassName，这个是prototy.js中的一个标准函数，但是单独运行版却是多种多样，而且兼容性很差，本来想扩展object.prototype.getElementsByClassName，但是发现时好时坏，兼容性很差。后来就google到了这么一个函数，貌似很不错的说。     http://robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/     http://code.google.com/p/getelementsbyclassname/          二、不多说，上代码       getElementsByClassName:
var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm [...]]]></description>
		<wfw:commentRss>http://newsn.net/20090629/725.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>cakephp的debugkit在ie下的再次修正</title>
		<link>http://newsn.net/20090623/616.html</link>
		<comments>http://newsn.net/20090623/616.html#comments</comments>
		<pubDate>Tue, 23 Jun 2009 03:39:15 +0000</pubDate>
		<dc:creator>苏南</dc:creator>
				<category><![CDATA[IT.IT]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[debugkit]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://newsn.net/20090623/616.html</guid>
		<description><![CDATA[Cakephp的debugkit在ie下面已经修正一次，可以正常显示toolbar，今天用了一下，发现还是有点问题，不能点击开具体页面中的小箭头显示详细内容，就再次修正增加了个event的target属性，具体如下：
 
一、写在前面      在msdn上面看到了这篇文章，应该是对ie下面的prototype进行修正的比较权威的文章。网上的文章都是在讲如何让ff支持ie的属性的，这里反其道而行，讲ie如何支持ff的属性。     http://msdn.microsoft.com/en-us/library/dd229916(VS.85).aspx
二、本次更新主要修改的问题     &#160; 这里的小箭头不能点开。    
三、增加后的代码     plugins\debug_kit\vendors\js\js_debug_toolbar.js
if (document.all){
	Event.prototype.preventDefault = function () {
	  this.returnValue = false;
	};
	Object.defineProperty(Event.prototype, 'target', {
	  get: function() {
	    return this.srcElement;
	  }
	});
}
这里面已经包含了上次对debugkit的更新修正。使用方法一样，放到这个js文件的开头就行了。
  这段JS的功用是： 
当前浏览器是IE(document.all)的时候,使得event这个类先增加一个方法叫做preventDefault，然后增加一个属性值叫做target。因为这2个东东都是ff特有的，ie不认识，而这个debugkit又是针对ff所写的，所以有此hook。
]]></description>
		<wfw:commentRss>http://newsn.net/20090623/616.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cakephp中使用JavaScriptHelper来引入js文件</title>
		<link>http://newsn.net/20090619/605.html</link>
		<comments>http://newsn.net/20090619/605.html#comments</comments>
		<pubDate>Fri, 19 Jun 2009 05:01:37 +0000</pubDate>
		<dc:creator>苏南</dc:creator>
				<category><![CDATA[IT.IT]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://newsn.net/20090619/605.html</guid>
		<description><![CDATA[页面的head部分的内容在Cakephp中主要是有htmlhelper来进行控制的，而js部分则是由JavaScripthelper来进行控制的，在controller里面设置好：var $helpers = array(&#8217;Html&#8217;,'Javascript&#8217;);就可以在ctp文件中使用JavaScripthelper对象：$javascript了。具体见正文。
 
前提是js文件都放在了 webroot/js&#160; 目录下面了，下面是范例。         1、$javascript-&#62;link($JsName,0); echo $script_for_layout;    在&#160; views/controllers/方法名.ctp文件里面，用$javascript-&#62;link($JsName,0);来把 webroot/js/jsname.js 文件加载到 views/layouts/default.ctp 的 $script_for_layout 里面去。         2、echo $javascript-&#62;link($JsName,1);      这句话是直接在views/layouts/default.ctp里面用的，放在head区就可以了，或者放置在 views/controllers/方法名.ctp文件 里面也是可以的。    
3、echo $javascript-&#62;includeScript();    [...]]]></description>
		<wfw:commentRss>http://newsn.net/20090619/605.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在css中引入css文件、以及在js中引入js文件的办法</title>
		<link>http://newsn.net/20090618/595.html</link>
		<comments>http://newsn.net/20090618/595.html#comments</comments>
		<pubDate>Thu, 18 Jun 2009 07:36:22 +0000</pubDate>
		<dc:creator>苏南</dc:creator>
				<category><![CDATA[IT.IT]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://newsn.net/20090618/595.html</guid>
		<description><![CDATA[当css或者js文件比较多的时候，老更改所有页面的代码是一件很崩溃的事情，这里讲的是只在代码里面引入一次，而通过这个被引入的文件来引入其他的css或者js。
 
一、css引入css      &#160;
二、js中引入js
]]></description>
		<wfw:commentRss>http://newsn.net/20090618/595.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>javascript的trim、replaceall、inarray</title>
		<link>http://newsn.net/20090615/576.html</link>
		<comments>http://newsn.net/20090615/576.html#comments</comments>
		<pubDate>Mon, 15 Jun 2009 06:54:23 +0000</pubDate>
		<dc:creator>苏南</dc:creator>
				<category><![CDATA[IT.IT]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://newsn.net/20090615/576.html</guid>
		<description><![CDATA[都是用正则表达式重写的prototype，很好用的说。
 
String.prototype.trim = function() {
	return this.replace(/(^\s*)&#124;(\s*$)/g, &#34;&#34;);
}
String.prototype.replaceAll = function(search, replace){
	var regex = new RegExp(search, &#34;g&#34;);
	return this.replace(regex, replace);
}
Array.prototype.inArray = function (value){
  for (var i=0; i &#60; this.length; i++){
      if (this[i] === value){
          return true;
      }
  [...]]]></description>
		<wfw:commentRss>http://newsn.net/20090615/576.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在IE下面使用Cakephp的debug kit插件</title>
		<link>http://newsn.net/20090605/537.html</link>
		<comments>http://newsn.net/20090605/537.html#comments</comments>
		<pubDate>Fri, 05 Jun 2009 10:02:50 +0000</pubDate>
		<dc:creator>苏南</dc:creator>
				<category><![CDATA[IT.IT]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[debugkit]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://newsn.net/20090605/537.html</guid>
		<description><![CDATA[Cakephp下面有个debugkit插件，是用来显示相关调试信息的。而且据说得到了Cakephp的作者之一的mark story的大力推荐，但是这个东东在ie下面却是不能使用的。本文说明如何在ie下面使用这个东东。

 

一、使用debugkit     官方网站是：http://thechaw.com/debug_kit/versions     写本文时，这个插件的最新版本是1.1。它的安装和使用很简单，     官方的readme是：
Installation
------------
 * Copy the files in this directory into app/plugins/debug_kit
 * Include the toolbar component in your app_controller.php:
	var $components = array('DebugKit.Toolbar');
 * Set debug mode to at least 1.
下载的脚本放置到app目录下的plugins目录就行了，然后在AppController里面用components来引入就行了。具体见图：

然后就会在你的app界面上出现如下toolbar。

点击对应的东东就可以显示相关的信息了。
关于debug的级别是在config/core.php 中用Configure::write(&#8217;debug&#8217;, 2);来控制的，注意修改就行啦。
但是这个toolbar有个致命的问题，就是在ie下面不能正常使用。
二、针对ie的修改
经过查看报错信息，发现原来是ie下不能识别event.preventDefault();的缘故。为了兼容IE，特地修改了ie下的event的prototype，让他支持event.preventDefault()方法。如下：
Event.prototype.preventDefault = function () {
  this.returnValue = [...]]]></description>
		<wfw:commentRss>http://newsn.net/20090605/537.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>firefox下javascript的getyear函数出错的解决方案</title>
		<link>http://newsn.net/20090515/423.html</link>
		<comments>http://newsn.net/20090515/423.html#comments</comments>
		<pubDate>Fri, 15 May 2009 13:27:08 +0000</pubDate>
		<dc:creator>苏南</dc:creator>
				<category><![CDATA[IT.IT]]></category>
		<category><![CDATA[代码修改]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://newsn.net/20090515/423.html</guid>
		<description><![CDATA[一、问题描述     &#160;&#160;&#160;&#160;&#160; 最近需要在个项目里面写个函数获取当前时间。没有想到，获取当前年份的函数在firefox下面出错，难道是ie和ff下的js解释引擎不一样导致的？找个问题还是头一次碰到。主要是getyear返回值不一致造成的。在ie下getyear得到的是2009，而ff下面得到的是109。

 

二、代码片段             其实也是很简单的东东，基本代码如下：     var now= new Date();     var year=now.getFullYear();     //firefox cant use getyear     var month=now.getMonth()+1;     var day=now.getDate(); [...]]]></description>
		<wfw:commentRss>http://newsn.net/20090515/423.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
