<?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://www.ecoviews.cn/archives/category/computer/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ecoviews.cn</link>
	<description>人生的三要素：思想 物质 能力---记录生活，改变自己！</description>
	<lastBuildDate>Sat, 14 Jan 2012 05:12:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>!document.getElementById等的说明！</title>
		<link>http://www.ecoviews.cn/archives/871.html</link>
		<comments>http://www.ecoviews.cn/archives/871.html#comments</comments>
		<pubDate>Fri, 28 May 2010 02:14:42 +0000</pubDate>
		<dc:creator>若水思源</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[document]]></category>

		<guid isPermaLink="false">http://www.ecoviews.cn/?p=871</guid>
		<description><![CDATA[对于在JavaScript中!document.getElementById、!document.createTextNode等这样的形式该如何理解，我想很多人并不是非常的清楚，但是看了以下的代码我想我们就会有一个非常深刻的理解。


相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/107.html' rel='bookmark' title='Permanent Link: 选择下拉列表实现跳转！'>选择下拉列表实现跳转！</a></li>
<li><a href='http://www.ecoviews.cn/archives/385.html' rel='bookmark' title='Permanent Link: 给自己的页面添加复制文章内容功能！'>给自己的页面添加复制文章内容功能！</a></li>
<li><a href='http://www.ecoviews.cn/archives/834.html' rel='bookmark' title='Permanent Link: Unicode字符编码与ASCII字符编码的关系！'>Unicode字符编码与ASCII字符编码的关系！</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>对于在JavaScript中!document.getElementById、!document.createTextNode等这样的形式该如何理解，我想很多人并不是非常的清楚，但是看了以下的代码我想我们就会有一个非常深刻的理解。</p>
<pre>&lt;html&gt;
&lt;script type="text/javascript"&gt;
alert(document);
/* 说明document为一个对象*/
alert(document.getElementById);
alert(document.createTextNode);
/*显示document对象是否定义getElementById与createTextNode，
   由于定义了，因此显示其定义的方法原型
*/
alert(document.getElementByClass);
/*由于document对象未定义getElementByClass方法，所以显示undefined*/</pre>
<pre>/*明确上面的一些知识对于我们理解下面的一段代码非常有帮助*/
function checkSearch()
{
 if(!document.getElementById||!document.createTextNode)
 {
  return;
 }
 .......
 /*即，如果document对象没有定义getElementById与createTextNode方法，则函数停止执行*/
}
&lt;/script&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<pre>其相关的执行结果如下所示（执行环境为IE6内核的浏览器）：</pre>
<pre>alert(document);
<a href="http://www.ecoviews.cn/wp-content/uploads/2010/05/object.png"><img class="alignnone size-full wp-image-872" title="object" src="http://www.ecoviews.cn/wp-content/uploads/2010/05/object.png" alt="" width="196" height="122" /></a></pre>
<pre>alert(document.getElementById);
<a href="http://www.ecoviews.cn/wp-content/uploads/2010/05/getElementById.png"><img class="alignnone size-full wp-image-873" title="getElementById" src="http://www.ecoviews.cn/wp-content/uploads/2010/05/getElementById.png" alt="" width="208" height="146" /></a></pre>
<pre>alert(document.createTextNode);
<a href="http://www.ecoviews.cn/wp-content/uploads/2010/05/createTextNode.png"><img class="alignnone size-full wp-image-874" title="createTextNode" src="http://www.ecoviews.cn/wp-content/uploads/2010/05/createTextNode.png" alt="" width="212" height="142" /></a></pre>
<pre>alert(document.getElementByClass);
<a href="http://www.ecoviews.cn/wp-content/uploads/2010/05/undefined.png"><img class="alignnone size-full wp-image-875" title="undefined" src="http://www.ecoviews.cn/wp-content/uploads/2010/05/undefined.png" alt="" width="199" height="122" /></a>
</pre>


<p>相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/107.html' rel='bookmark' title='Permanent Link: 选择下拉列表实现跳转！'>选择下拉列表实现跳转！</a></li>
<li><a href='http://www.ecoviews.cn/archives/385.html' rel='bookmark' title='Permanent Link: 给自己的页面添加复制文章内容功能！'>给自己的页面添加复制文章内容功能！</a></li>
<li><a href='http://www.ecoviews.cn/archives/834.html' rel='bookmark' title='Permanent Link: Unicode字符编码与ASCII字符编码的关系！'>Unicode字符编码与ASCII字符编码的关系！</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ecoviews.cn/archives/871.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript中文、英文字符串比较！</title>
		<link>http://www.ecoviews.cn/archives/842.html</link>
		<comments>http://www.ecoviews.cn/archives/842.html#comments</comments>
		<pubDate>Wed, 26 May 2010 00:55:04 +0000</pubDate>
		<dc:creator>若水思源</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[字符串]]></category>

		<guid isPermaLink="false">http://www.ecoviews.cn/?p=842</guid>
		<description><![CDATA[在使用JavaScript中，我们常常知道比较两个英文字符串是根据字符本身的ASCII码的大小，从左往右进行比较（很多教程上都这么说）。但是对于这样一种说法我认为不合适，毕竟字符串中不仅有英文，而且有中文，对于中文的比较也可以的，但是ASCII码却不能表示中文。


相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/107.html' rel='bookmark' title='Permanent Link: 选择下拉列表实现跳转！'>选择下拉列表实现跳转！</a></li>
<li><a href='http://www.ecoviews.cn/archives/111.html' rel='bookmark' title='Permanent Link: 竖向伸缩列表的做法！'>竖向伸缩列表的做法！</a></li>
<li><a href='http://www.ecoviews.cn/archives/385.html' rel='bookmark' title='Permanent Link: 给自己的页面添加复制文章内容功能！'>给自己的页面添加复制文章内容功能！</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>在使用JavaScript中，我们常常知道比较两个英文字符串是根据字符本身的ASCII码的大小，从左往右进行比较（很多教程上都这么说）。但是对于这样一种说法我认为不合适，毕竟字符串中不仅有英文，而且有中文，对于中文的比较也可以的，但是ASCII码却不能表示中文。</p>
<p>因此，我想JavaScript的字符串比较应该换成另一种说法，那就是按照字符的Unicode码的大小从左至右进行比较。当然为何是Unicode码而不是其它的编码，我想这是跟我们页面的编码有关吧，但是到底是不是这样，我也没有查到相关的信息，如果你有这方面的资料，请告知于我，不胜感激。</p>
<p>证明我上面所说的一个测试程序如下：页面编码utf-8</p>
<pre>&lt;html&gt;
&lt;body&gt;
&lt;script type="text/javascript"&gt;
 var str1="Apple";
 var str2="Banana";
 document.write(str1&gt;str2);
 document.write("&lt;br /&gt;");
 /*
 执行结果为：FALSE,因为JavaScript中字符串的比较是按照字符的ASCII码，从左至右进行比较的。
 但是对于中文比较呢？
 由于中文不能使用ASCII码进行表示，但是却可以使用Unicode码表示，那么是否在进行中文字符串比较时
 是按照字符的Unicode值的大小进行比较的呢？
 如果真是这样的话，那么是否意味着所有的中文字符都比英文字符都大呢？
 */
 /*中文字符比英文字符要大*/
 var str3="中国";
 var str4="ZZ";
 document.write(str3&gt;str4);
 document.write("&lt;br /&gt;");
 /*执行结果为：true*/
 
 var str5="中国";
 var str6="人民";
 /*显示str5中第一个字符的Unicode值*/
 document.write(str5.charCodeAt(0));
 document.write("&lt;br /&gt;");
 /*显示str6中第一个字符的Unicode值*/
 document.write(str6.charCodeAt(0));
 document.write("&lt;br /&gt;");
 /*显示比较的结果*/
 document.write(str5&gt;str6);
 document.write("&lt;br /&gt;");
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<pre>执行结果如下：</pre>
<pre>false
true
20013
20154
false</pre>
<p>从中我们可以得到这样的一个规律：所有的中文字符都比英文字符要大！</p>


<p>相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/107.html' rel='bookmark' title='Permanent Link: 选择下拉列表实现跳转！'>选择下拉列表实现跳转！</a></li>
<li><a href='http://www.ecoviews.cn/archives/111.html' rel='bookmark' title='Permanent Link: 竖向伸缩列表的做法！'>竖向伸缩列表的做法！</a></li>
<li><a href='http://www.ecoviews.cn/archives/385.html' rel='bookmark' title='Permanent Link: 给自己的页面添加复制文章内容功能！'>给自己的页面添加复制文章内容功能！</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ecoviews.cn/archives/842.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unicode字符编码与ASCII字符编码的关系！</title>
		<link>http://www.ecoviews.cn/archives/834.html</link>
		<comments>http://www.ecoviews.cn/archives/834.html#comments</comments>
		<pubDate>Mon, 24 May 2010 02:02:11 +0000</pubDate>
		<dc:creator>若水思源</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ASCII]]></category>
		<category><![CDATA[Unicode]]></category>

		<guid isPermaLink="false">http://www.ecoviews.cn/?p=834</guid>
		<description><![CDATA[ASCII字符编码是一种7位编码，范围从0x00-0x7F，包括了英文字母，阿拉伯数字，标点符号，控制字符等，其中0x00-0x20和0x7F表示控制字符。


相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/111.html' rel='bookmark' title='Permanent Link: 竖向伸缩列表的做法！'>竖向伸缩列表的做法！</a></li>
<li><a href='http://www.ecoviews.cn/archives/385.html' rel='bookmark' title='Permanent Link: 给自己的页面添加复制文章内容功能！'>给自己的页面添加复制文章内容功能！</a></li>
<li><a href='http://www.ecoviews.cn/archives/842.html' rel='bookmark' title='Permanent Link: JavaScript中文、英文字符串比较！'>JavaScript中文、英文字符串比较！</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>ASCII字符编码是一种7位编码，范围从0&#215;00-0x7F，包括了英文字母，阿拉伯数字，标点符号，控制字符等，其中0&#215;00-0&#215;20和0x7F表示控制字符。</p>
<p>换句话说，ASCII字符编码的编码范围为：0-254，其中0-32与127为控制字符。</p>
<p>Unicode字符编码的编码范围是：0-65535，它包含三套编码方式如：UTF-8，UTF-16和UTF-32。它和ASCII的关系为ASCII字符编码是Unicode字符编码的一部分。</p>
<p>懂得这点知识可以帮助我们理解这些方面的内容：<br />
1.怎么识别一段文字中，那些是中文，哪些是英文。<br />
2.在分割字符串时候，我们对于乱码的解决等等。</p>
<p>下面以一段JavaScript代码为例来进行说明，其中网页编码为utf-8。</p>
<pre>&lt;script type="text/javascript"&gt;
 var str="测试一个文档中的English与Chinese，并把其中的中英文分开。";
 var len=str.length;
 document.write("测试字符的长度："+len);
 document.write("&lt;br /&gt;");
 for(i=0;i&lt;len;i++)
 {
  unicode_num=str.charCodeAt(i);
  document.writeln(unicode_num);
  if(unicode_num&lt;255)
  {
   char=str.charAt(i);
   document.write(char+"该字符为英文");
   document.write("&lt;br /&gt;");
  }
  else
  {
   char=str.charAt(i);
   document.write(char+"该字符为中文");
   document.write("&lt;br /&gt;");
  }
 }
&lt;/script&gt;</pre>
<p>通过运行的结果我们可以发现以下一些事实：<br />
1.当网页编码为utf-8，gb2312时，字符长度是35，即是说中文字符与英文字符所用的编码格式都是相同的。<br />
2.在中文输入法下，标点符号是中文而不是英文。如上面的逗号、句号。<br />
3.因为中英文编码的格式是相同的，因此在进行字符串分割时不用考虑因为进行字符的裁剪而造成乱码的问题。而这是在php进行字符分割时要考虑的。</p>
<p>懂得上面的一些知识可以在以下的一些应用中指导我们：<br />
1.对网页进行内容的提取。<br />
2.统计一篇文章中总字符的个数，中文字符，非中文字符的个数，如Word里面的字数统计功能。（当然上面的仅仅是一个非常粗略的算法，即如果一个字符的Unicode值小于255则为英文，反正为中文，但是实际上却比这个要细得多，但是这样的一种方法可以作为一种粗略的统计工具，在很多的应用中已经足够使用，如上面的测试程序中。）<br />
3.能在字符串剪裁中给予我们指导。</p>


<p>相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/111.html' rel='bookmark' title='Permanent Link: 竖向伸缩列表的做法！'>竖向伸缩列表的做法！</a></li>
<li><a href='http://www.ecoviews.cn/archives/385.html' rel='bookmark' title='Permanent Link: 给自己的页面添加复制文章内容功能！'>给自己的页面添加复制文章内容功能！</a></li>
<li><a href='http://www.ecoviews.cn/archives/842.html' rel='bookmark' title='Permanent Link: JavaScript中文、英文字符串比较！'>JavaScript中文、英文字符串比较！</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ecoviews.cn/archives/834.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Alexa重定向实现方式！</title>
		<link>http://www.ecoviews.cn/archives/466.html</link>
		<comments>http://www.ecoviews.cn/archives/466.html#comments</comments>
		<pubDate>Thu, 04 Mar 2010 07:37:05 +0000</pubDate>
		<dc:creator>若水思源</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[alexa]]></category>
		<category><![CDATA[Alexa重定向]]></category>

		<guid isPermaLink="false">http://www.ecoviews.cn/?p=466</guid>
		<description><![CDATA[  在今天我在查找如果提高自己网站的Alexa排名的时候，其中的一个方法就是把自己的网站的链接变成Alexa的重定向链接，如下面的链接所示：   http://redirect.alexa.com/redirect?www.ecoviews.cn 任何人只有点击了这个链接，那么都可以给我的Alexa排名做贡献，有趣的是我们打开的网页却仍然是我们自己网站的网页，不信的话你可以点击此处查看，打开的就是我网站的主页，却不是Alexa的网站。 但是我们在来看看下面的这种情况： 代码如下： 点击进入&#60;a href=&#8221;http://www.baidu.com?www.google.cn&#8220;&#62;百度网站&#60;/a&#62; 效果为：点击进入百度网站，你会发现打开的网站却是百度的，而不是谷歌的网站，那么你就会想，Alexa的这种重定向是如何实现的的？    这个功能完全可以使用JavaScript来实现，如你要打开的地址为：http://127.0.0.1/phpstudy/test.html?www.ecoviews.cn 你只需在你的test.html文件中写入以下的代码就可以。 &#60;script type=&#8221;text/javascript&#8221;&#62; var localurl =window.location.href; var url=localurl.split(&#8220;?&#8221;); window.location.href=&#8221;http://&#8221;+url[1]; &#60;/script&#62;   实现的原理就是：获得？后面的url，然后在跳转到该地址就行了，因此能够实现这样功能的方法还有很多，上面的仅仅是一种而已。 相关文章:选择下拉列表实现跳转！ window.location与window.location.href 给自己的页面添加复制文章内容功能！


相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/107.html' rel='bookmark' title='Permanent Link: 选择下拉列表实现跳转！'>选择下拉列表实现跳转！</a></li>
<li><a href='http://www.ecoviews.cn/archives/309.html' rel='bookmark' title='Permanent Link: window.location与window.location.href'>window.location与window.location.href</a></li>
<li><a href='http://www.ecoviews.cn/archives/385.html' rel='bookmark' title='Permanent Link: 给自己的页面添加复制文章内容功能！'>给自己的页面添加复制文章内容功能！</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>  在今天我在查找如果提高自己网站的Alexa排名的时候，其中的一个方法就是把自己的网站的链接变成Alexa的重定向链接，如下面的链接所示：</p>
<p>  <a href="http://redirect.alexa.com/redirect?www.ecoviews.cn">http://redirect.alexa.com/redirect?www.ecoviews.cn</a><br />
任何人只有点击了这个链接，那么都可以给我的Alexa排名做贡献，有趣的是我们打开的网页却仍然是我们自己网站的网页，不信的话你可以<a href="http://redirect.alexa.com/redirect?www.ecoviews.cn" target="_blank">点击此处查看</a>，打开的就是我网站的主页，却不是Alexa的网站。</p>
<p>但是我们在来看看下面的这种情况：</p>
<p>代码如下：<br />
点击进入&lt;a href=&#8221;<a href="http://www.baidu.com?http://www.google.cn">http://www.baidu.com?www.google.cn</a>&#8220;&gt;百度网站&lt;/a&gt;</p>
<p>效果为：点击进入<a href="http://www.baidu.com?www.google.cn" target="_blank">百度网站</a>，你会发现打开的网站却是百度的，而不是谷歌的网站，那么你就会想，Alexa的这种重定向是如何实现的的？</p>
<p>   这个功能完全可以使用JavaScript来实现，如你要打开的地址为：<a href="http://127.0.0.1/phpstudy/test.html?www.ecoviews.cn">http://127.0.0.1/phpstudy/test.html?www.ecoviews.cn</a></p>
<p>你只需在你的test.html文件中写入以下的代码就可以。</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var localurl =window.location.href;<br />
var url=localurl.split(&#8220;?&#8221;);<br />
window.location.href=&#8221;<a href="http://&quot;+url[1">http://&#8221;+url[1</a>];<br />
&lt;/script&gt;</p>
<p>  实现的原理就是：获得？后面的url，然后在跳转到该地址就行了，因此能够实现这样功能的方法还有很多，上面的仅仅是一种而已。</p>


<p>相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/107.html' rel='bookmark' title='Permanent Link: 选择下拉列表实现跳转！'>选择下拉列表实现跳转！</a></li>
<li><a href='http://www.ecoviews.cn/archives/309.html' rel='bookmark' title='Permanent Link: window.location与window.location.href'>window.location与window.location.href</a></li>
<li><a href='http://www.ecoviews.cn/archives/385.html' rel='bookmark' title='Permanent Link: 给自己的页面添加复制文章内容功能！'>给自己的页面添加复制文章内容功能！</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ecoviews.cn/archives/466.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>编码对JavaScript的影响！</title>
		<link>http://www.ecoviews.cn/archives/400.html</link>
		<comments>http://www.ecoviews.cn/archives/400.html#comments</comments>
		<pubDate>Sun, 24 Jan 2010 03:08:05 +0000</pubDate>
		<dc:creator>若水思源</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[编码]]></category>

		<guid isPermaLink="false">http://www.ecoviews.cn/?p=400</guid>
		<description><![CDATA[这几天自己在做一个网站，在实现新闻列表选择的时候自己想实现下面这样的功能： 1.如果用户的鼠标不在某条新闻上时，新闻背景显示为背景色。 2.如果用户的鼠标在某条新闻上时，新闻背景显示为白色。 一个图例如下所示： 但是可惜的是我写了JavaScript代码，但是不知道为什么总是不起作用，我的JavaScript代码如下所示：    后来自己找到了原因所在：原因是自己的网页编码为utf-8的格式，而JavaScript代码为gb2312的格式，结果造成了JavaScript代码不起作用。 后台把JavaScript代码改为utf-8的格式后，成功了。 做法就是：用记事本打开js文件，然后另存为，在另存为选择编码为utf-8。 如下图所示： 没有相关文章.


没有相关文章.]]></description>
			<content:encoded><![CDATA[<p>这几天自己在做一个网站，在实现新闻列表选择的时候自己想实现下面这样的功能：</p>
<p>1.如果用户的鼠标不在某条新闻上时，新闻背景显示为背景色。</p>
<p>2.如果用户的鼠标在某条新闻上时，新闻背景显示为白色。</p>
<p>一个图例如下所示：</p>
<p><a href="http://www.ecoviews.cn/wp-content/uploads/2010/01/newslist1.png"><img class="alignnone size-full wp-image-409" title="newslist" src="http://www.ecoviews.cn/wp-content/uploads/2010/01/newslist1.png" alt="" width="555" height="96" /></a></p>
<p><a href="http://www.ecoviews.cn/wp-content/uploads/2010/01/newslist.png"></a></p>
<p>但是可惜的是我写了JavaScript代码，但是不知道为什么总是不起作用，我的JavaScript代码如下所示：</p>
<p> <a href="http://www.ecoviews.cn/wp-content/uploads/2010/01/JavaScript.png"><img class="alignnone size-medium wp-image-404" title="JavaScript代码" src="http://www.ecoviews.cn/wp-content/uploads/2010/01/JavaScript-300x160.png" alt="" width="349" height="162" /></a> </p>
<p>后来自己找到了原因所在：原因是自己的网页编码为utf-8的格式，而JavaScript代码为gb2312的格式，结果造成了JavaScript代码不起作用。</p>
<p>后台把JavaScript代码改为utf-8的格式后，成功了。</p>
<p>做法就是：用记事本打开js文件，然后另存为，在另存为选择编码为utf-8。</p>
<p>如下图所示：</p>
<p><a href="http://www.ecoviews.cn/wp-content/uploads/2010/01/text.png"><img class="alignnone size-medium wp-image-405" title="记事本另存为" src="http://www.ecoviews.cn/wp-content/uploads/2010/01/text-300x67.png" alt="" width="300" height="67" /></a></p>


<p>没有相关文章.</p>]]></content:encoded>
			<wfw:commentRss>http://www.ecoviews.cn/archives/400.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>给自己的页面添加复制文章内容功能！</title>
		<link>http://www.ecoviews.cn/archives/385.html</link>
		<comments>http://www.ecoviews.cn/archives/385.html#comments</comments>
		<pubDate>Fri, 15 Jan 2010 11:41:57 +0000</pubDate>
		<dc:creator>若水思源</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web开发]]></category>
		<category><![CDATA[网站建设]]></category>

		<guid isPermaLink="false">http://www.ecoviews.cn/?p=385</guid>
		<description><![CDATA[  对于任何一个想在网络中找到自己想要的资料的人来说，找到自己想要的资料的时候是非常开心的事情的，毕竟这就意味着自己的问题得到了解决，自己不用再为了这个疑难而劳神伤心！   不过我们常常在找到资料的时候感到不愉快，因为现在的网页制作不知道是怎么了，也许是网站主为了故意想让我们这些浏览者点击广告吧，他们常常把一些广告放在了网页的文章之中，当然这并不可厚非，毕竟网站主最主要或者说唯一的收入来源就是网站的广告。但是如果网站主仅仅是为了想增加自己的收入而不顾我们浏览者的感受的话，我想这样的网站主不是一个合格的。   举一个简单的例子来说，当我们查找到我们需要的资料的时候，我们往往希望把这些资料给保存下来，一方面是怕自己以后再遇到相似问题时自己忘记了，二是避免自己以后忘记时再宠信花时间去查找这些资料，但是如果网站的站主禁止了页面的复制功能，或者是网站的站主在页面中嵌入了广告的话，那么着对于我们浏览者来说是不好的，一是不能保存我们需要的资料，二是我们在复制资料时十分的麻烦。当然我们浏览者也要加强自己的版权意识，毕竟很多网站禁止复制的原因就是为了保护自己的版权，而这正是我们网站浏览者所忽视的。   不过在我看来，一个博客应该是以浏览者为主的，能为浏览者考虑的网站是才算得上是一个优秀的网站，因此如果一个网站能够提供一个复制网站文章内容的功能的话，我想就可以减轻我们浏览者很多的麻烦，毕竟每次选中我们要复制的文字本身是一件麻烦的事情，而实现这样的功能本身也非常的简单。   下面我们用JavaScript来实现！具体的代码如下： &#60;script type=&#8221;text/javascript&#8221;&#62; // &#60;![CDATA[ function copy_clip(copy) { copy="碧水轩&#124;http://www.ecoviews.cn \r\n"+copy; if (window.clipboardData) { window.clipboardData.setData("Text", copy); } else if (window.netscape) { netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); if (!clip) return; var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); if (!trans) return; trans.addDataFlavor(&#8216;text/unicode&#8217;); var str = new Object(); var len = new Object(); [...]


相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/466.html' rel='bookmark' title='Permanent Link: Alexa重定向实现方式！'>Alexa重定向实现方式！</a></li>
<li><a href='http://www.ecoviews.cn/archives/834.html' rel='bookmark' title='Permanent Link: Unicode字符编码与ASCII字符编码的关系！'>Unicode字符编码与ASCII字符编码的关系！</a></li>
<li><a href='http://www.ecoviews.cn/archives/842.html' rel='bookmark' title='Permanent Link: JavaScript中文、英文字符串比较！'>JavaScript中文、英文字符串比较！</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>  对于任何一个想在网络中找到自己想要的资料的人来说，找到自己想要的资料的时候是非常开心的事情的，毕竟这就意味着自己的问题得到了解决，自己不用再为了这个疑难而劳神伤心！</p>
<p>  不过我们常常在找到资料的时候感到不愉快，因为现在的网页制作不知道是怎么了，也许是网站主为了故意想让我们这些浏览者点击广告吧，他们常常把一些广告放在了网页的文章之中，当然这并不可厚非，毕竟网站主最主要或者说唯一的收入来源就是网站的广告。但是如果网站主仅仅是为了想增加自己的收入而不顾我们浏览者的感受的话，我想这样的网站主不是一个合格的。</p>
<p>  举一个简单的例子来说，当我们查找到我们需要的资料的时候，我们往往希望把这些资料给保存下来，一方面是怕自己以后再遇到相似问题时自己忘记了，二是避免自己以后忘记时再宠信花时间去查找这些资料，但是如果网站的站主禁止了页面的复制功能，或者是网站的站主在页面中嵌入了广告的话，那么着对于我们浏览者来说是不好的，一是不能保存我们需要的资料，二是我们在复制资料时十分的麻烦。当然我们浏览者也要加强自己的版权意识，毕竟很多网站禁止复制的原因就是为了保护自己的版权，而这正是我们网站浏览者所忽视的。</p>
<p>  不过在我看来，一个博客应该是以浏览者为主的，能为浏览者考虑的网站是才算得上是一个优秀的网站，因此如果一个网站能够提供一个复制网站文章内容的功能的话，我想就可以减轻我们浏览者很多的麻烦，毕竟每次选中我们要复制的文字本身是一件麻烦的事情，而实现这样的功能本身也非常的简单。</p>
<p>  下面我们用JavaScript来实现！具体的代码如下：</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;</p>
<p>// &lt;![CDATA[</p>
<p>function copy_clip(copy)</p>
<p>{</p>
<p>copy="碧水轩|http://www.ecoviews.cn \r\n"+copy;</p>
<p>if (window.clipboardData)</p>
<p>{</p>
<p>window.clipboardData.setData("Text", copy);</p>
<p>}</p>
<p>else</p>
<p>if (window.netscape)</p>
<p>{</p>
<p>netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');</p>
<p>var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);</p>
<p>if (!clip) return;</p>
<p>var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);</p>
<p>if (!trans) return;</p>
<p>trans.addDataFlavor(&#8216;text/unicode&#8217;);</p>
<p>var str = new Object();</p>
<p>var len = new Object();</p>
<p>var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);</p>
<p>var copytext=copy;</p>
<p>str.data=copytext;</p>
<p>trans.setTransferData(&#8220;text/unicode&#8221;,str,copytext.length*2);</p>
<p>var clipid=Components.interfaces.nsIClipboard;</p>
<p>if (!clip) return false;</p>
<p>clip.setData(trans,null,clipid.kGlobalClipboard);</p>
<p>}</p>
<p>alert(&#8220;内容已经复制到剪切板！&#8221;)</p>
<p>}</p>
<p>// ]]&gt;</p>
<p>&lt;/script&gt;</p>
<p>&lt;!&#8211;以上为主要代码&#8211;&gt;</p>
<p>&lt;input type=&#8221;text&#8221; id=&#8221;ff&#8221; value=&#8221;www.baidu.com&#8221; /&gt;&lt;button onclick=&#8221;copy_clip(document.getElementById(&#8216;ff&#8217;).value)&#8221;&gt;复制</p>
<p>&lt;/button&gt;</p>


<p>相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/466.html' rel='bookmark' title='Permanent Link: Alexa重定向实现方式！'>Alexa重定向实现方式！</a></li>
<li><a href='http://www.ecoviews.cn/archives/834.html' rel='bookmark' title='Permanent Link: Unicode字符编码与ASCII字符编码的关系！'>Unicode字符编码与ASCII字符编码的关系！</a></li>
<li><a href='http://www.ecoviews.cn/archives/842.html' rel='bookmark' title='Permanent Link: JavaScript中文、英文字符串比较！'>JavaScript中文、英文字符串比较！</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ecoviews.cn/archives/385.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>window.location与window.location.href</title>
		<link>http://www.ecoviews.cn/archives/309.html</link>
		<comments>http://www.ecoviews.cn/archives/309.html#comments</comments>
		<pubDate>Sat, 02 Jan 2010 11:24:28 +0000</pubDate>
		<dc:creator>若水思源</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[window]]></category>

		<guid isPermaLink="false">http://www.ecoviews.cn/?p=309</guid>
		<description><![CDATA[  在通常情况下，我们使用window.location=URL与window.location.href=URL来进行页面的跳转时没有什么不同，在IE与Firefox下我自己测试过，无论是URL是绝对路径还是相对路径，两者都可以起作用。   但是仔细再Google上查找了相似的问题，却发现原来另有情况，那就是： （源地址：http://www.cnpublic.com/2009/06/windowlocationhref-invalid/）   浏览器区别:IE或者Firefox2.0.x下,可以使用window.location或window.location.href; Firefox1.5.x下,只能使用window.location. 相关文章:选择下拉列表实现跳转！ 竖向伸缩列表的做法！ JavaScript向PHP的传递变量的两种方式！


相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/107.html' rel='bookmark' title='Permanent Link: 选择下拉列表实现跳转！'>选择下拉列表实现跳转！</a></li>
<li><a href='http://www.ecoviews.cn/archives/111.html' rel='bookmark' title='Permanent Link: 竖向伸缩列表的做法！'>竖向伸缩列表的做法！</a></li>
<li><a href='http://www.ecoviews.cn/archives/124.html' rel='bookmark' title='Permanent Link: JavaScript向PHP的传递变量的两种方式！'>JavaScript向PHP的传递变量的两种方式！</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>  在通常情况下，我们使用window.location=URL与window.location.href=URL来进行页面的跳转时没有什么不同，在IE与Firefox下我自己测试过，无论是URL是绝对路径还是相对路径，两者都可以起作用。</p>
<p>  但是仔细再Google上查找了相似的问题，却发现原来另有情况，那就是：</p>
<p>（源地址：http://www.cnpublic.com/2009/06/windowlocationhref-invalid/）</p>
<p>  浏览器区别:IE或者Firefox2.0.x下,可以使用window.location或window.location.href;</p>
<p>Firefox1.5.x下,只能使用window.location.</p>


<p>相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/107.html' rel='bookmark' title='Permanent Link: 选择下拉列表实现跳转！'>选择下拉列表实现跳转！</a></li>
<li><a href='http://www.ecoviews.cn/archives/111.html' rel='bookmark' title='Permanent Link: 竖向伸缩列表的做法！'>竖向伸缩列表的做法！</a></li>
<li><a href='http://www.ecoviews.cn/archives/124.html' rel='bookmark' title='Permanent Link: JavaScript向PHP的传递变量的两种方式！'>JavaScript向PHP的传递变量的两种方式！</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ecoviews.cn/archives/309.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>竖向伸缩列表的做法！</title>
		<link>http://www.ecoviews.cn/archives/111.html</link>
		<comments>http://www.ecoviews.cn/archives/111.html#comments</comments>
		<pubDate>Sat, 19 Sep 2009 05:56:12 +0000</pubDate>
		<dc:creator>若水思源</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[列表]]></category>

		<guid isPermaLink="false">http://www.baoway.net.cn/?p=348</guid>
		<description><![CDATA[ 在进行web开发的过程中，后台管理是一个非常重要的部分，而后台管理又常常因为数据的条目和类别太多使我们的网页设计人员常常感到头痛，毕竟有时常常得考虑在一个页面中显示很多的条目与内容，但是却又要保持页面的视觉效果，而这两者之间又常常是想冲突的。因此在我们进行后台设计时，引入一种竖向或者横向的伸缩列表，达到显示内容与视觉效果相和谐的目的。   伸缩列表有两种，一种是竖向的，这种常常在后台中使用，模拟的是电脑中文件夹的操作，而横向的更多的是用于网站的前台导航。因此，在这我们先介绍竖向伸缩列表的做法。   效果图如下所示：    该图是页面开始运行是的效果图，在每一个类别下面有若干小类，我们只要点击相应的类别就可以把相关类别展开，效果图如下所示，在点击一次，相关类别收缩。   其功能的实现方式是通过JavaScript来控制相应元素的显示与隐藏，关键的JavaScript代码如下：  function go(index) { var images=document.images; if(images[index].src.indexOf(&#8220;add&#8221;)!=-1) images[index].src=&#8221;images/dec.jpg&#8221;; else images[index].src=&#8221;images/add.png&#8221;;  var tables=document.getElementsByTagName(&#8220;table&#8221;);//.length;index=2*index+1;  if(tables[index].style.display==&#8221;none&#8221;)  tables[index].style.display=&#8221;block&#8221;;  else  tables[index].style.display=&#8221;none&#8221;; } &#60;/script&#62;   你也可以通过点击这里获取该文件的原代码。 相关文章:JavaScript中文、英文字符串比较！ 给自己的页面添加复制文章内容功能！ Unicode字符编码与ASCII字符编码的关系！


相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/842.html' rel='bookmark' title='Permanent Link: JavaScript中文、英文字符串比较！'>JavaScript中文、英文字符串比较！</a></li>
<li><a href='http://www.ecoviews.cn/archives/385.html' rel='bookmark' title='Permanent Link: 给自己的页面添加复制文章内容功能！'>给自己的页面添加复制文章内容功能！</a></li>
<li><a href='http://www.ecoviews.cn/archives/834.html' rel='bookmark' title='Permanent Link: Unicode字符编码与ASCII字符编码的关系！'>Unicode字符编码与ASCII字符编码的关系！</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p> 在进行web开发的过程中，后台管理是一个非常重要的部分，而后台管理又常常因为数据的条目和类别太多使我们的网页设计人员常常感到头痛，毕竟有时常常得考虑在一个页面中显示很多的条目与内容，但是却又要保持页面的视觉效果，而这两者之间又常常是想冲突的。因此在我们进行后台设计时，引入一种竖向或者横向的伸缩列表，达到显示内容与视觉效果相和谐的目的。</p>
<p>  伸缩列表有两种，一种是竖向的，这种常常在后台中使用，模拟的是电脑中文件夹的操作，而横向的更多的是用于网站的前台导航。因此，在这我们先介绍竖向伸缩列表的做法。</p>
<p>  效果图如下所示：<br />
 <img class="alignnone size-full wp-image-349" title="竖向列表1" src="http://www.baoway.net.cn/wp-content/uploads/2009/09/submenu1.png" alt="竖向列表1" width="202" height="85" /><br />
 该图是页面开始运行是的效果图，在每一个类别下面有若干小类，我们只要点击相应的类别就可以把相关类别展开，效果图如下所示，在点击一次，相关类别收缩。</p>
<p>  <img class="alignnone size-full wp-image-350" title="竖向列表2" src="http://www.baoway.net.cn/wp-content/uploads/2009/09/submenu2.png" alt="竖向列表2" width="199" height="246" /><br />
其功能的实现方式是通过JavaScript来控制相应元素的显示与隐藏，关键的JavaScript代码如下：</p>
<p> function go(index)<br />
{<br />
var images=document.images;<br />
if(images[index].src.indexOf(&#8220;add&#8221;)!=-1)<br />
images[index].src=&#8221;images/dec.jpg&#8221;;<br />
else<br />
images[index].src=&#8221;images/add.png&#8221;;<br />
 var tables=document.getElementsByTagName(&#8220;table&#8221;);//.length;index=2*index+1;<br />
 if(tables[index].style.display==&#8221;none&#8221;)<br />
 tables[index].style.display=&#8221;block&#8221;;<br />
 else<br />
 tables[index].style.display=&#8221;none&#8221;;<br />
}<br />
&lt;/script&gt;</p>
<p>  你也可以通过<a href="http://down.qiannao.com/space/show/yzlun/%E4%B8%8A%E4%BC%A0%E5%88%86%E4%BA%AB/computerscience/javascript/%E7%AB%96%E5%90%91%E4%BC%B8%E7%BC%A9%E5%88%97%E8%A1%A8.rar/.page" target="_blank">点击这里获取该文件的原代码</a>。</p>


<p>相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/842.html' rel='bookmark' title='Permanent Link: JavaScript中文、英文字符串比较！'>JavaScript中文、英文字符串比较！</a></li>
<li><a href='http://www.ecoviews.cn/archives/385.html' rel='bookmark' title='Permanent Link: 给自己的页面添加复制文章内容功能！'>给自己的页面添加复制文章内容功能！</a></li>
<li><a href='http://www.ecoviews.cn/archives/834.html' rel='bookmark' title='Permanent Link: Unicode字符编码与ASCII字符编码的关系！'>Unicode字符编码与ASCII字符编码的关系！</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ecoviews.cn/archives/111.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>选择下拉列表实现跳转！</title>
		<link>http://www.ecoviews.cn/archives/107.html</link>
		<comments>http://www.ecoviews.cn/archives/107.html#comments</comments>
		<pubDate>Fri, 18 Sep 2009 07:01:47 +0000</pubDate>
		<dc:creator>若水思源</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[列表]]></category>

		<guid isPermaLink="false">http://www.baoway.net.cn/?p=342</guid>
		<description><![CDATA[  在我们浏览网站的时候，我们可能遇到这样的一种情况，那就是网站提供给我们一个下拉列表，然后我们选择之后，网站自动地跳转到我们选择的页面。自己一个真实的体会就是在一次国外网站注册的过程中，自己通过下拉列表选择自己的国籍后，网站自动定位到了一个中文页面进行注册。   此时我们不禁会想，这样的功能我们应该怎么实现呢？实现有两种方法，一种是客服端进行实现&#8212;&#8211;使用JavaScript，另一种使用服务器端进行实现&#8212;利用PHP或JSP等动态语言实现，显而易见使用客服端要好，毕竟这样可以减少服务器的压力。   我通过一个实例来说说明，读者可以通过该实例来进行体会。 &#60;html&#62; &#60;head&#62;&#60;title&#62;下拉列表实现跳转&#60;/title&#62;&#60;/head&#62; &#60;body&#62; &#60;select onchange=&#8221;eval(&#8216;window.location=this.options[this.selectedIndex].value&#8217;)&#8221;&#62; &#60;option value=&#8221;1.html&#8221;&#62;1.html&#60;/option&#62; &#60;option value=&#8221;2.html&#8221;&#62;2.html&#60;/option&#62; &#60;option value=&#8221;3.html&#8221;&#62;3.html&#60;/option&#62; &#60;/body&#62; &#60;html&#62;   通过测试，可以实现我上面所说的内容，你可以通过这里来获取该源文件。 相关文章:!document.getElementById等的说明！ window.location与window.location.href 网站中超链接嵌套！


相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/871.html' rel='bookmark' title='Permanent Link: !document.getElementById等的说明！'>!document.getElementById等的说明！</a></li>
<li><a href='http://www.ecoviews.cn/archives/309.html' rel='bookmark' title='Permanent Link: window.location与window.location.href'>window.location与window.location.href</a></li>
<li><a href='http://www.ecoviews.cn/archives/463.html' rel='bookmark' title='Permanent Link: 网站中超链接嵌套！'>网站中超链接嵌套！</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>  在我们浏览网站的时候，我们可能遇到这样的一种情况，那就是网站提供给我们一个下拉列表，然后我们选择之后，网站自动地跳转到我们选择的页面。自己一个真实的体会就是在一次国外网站注册的过程中，自己通过下拉列表选择自己的国籍后，网站自动定位到了一个中文页面进行注册。</p>
<p>  此时我们不禁会想，这样的功能我们应该怎么实现呢？实现有两种方法，一种是客服端进行实现&#8212;&#8211;使用JavaScript，另一种使用服务器端进行实现&#8212;利用PHP或JSP等动态语言实现，显而易见使用客服端要好，毕竟这样可以减少服务器的压力。</p>
<p>  我通过一个实例来说说明，读者可以通过该实例来进行体会。</p>
<p>&lt;html&gt;<br />
&lt;head&gt;&lt;title&gt;下拉列表实现跳转&lt;/title&gt;&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;select onchange=&#8221;eval(&#8216;window.location=this.options[this.selectedIndex].value&#8217;)&#8221;&gt;<br />
&lt;option value=&#8221;1.html&#8221;&gt;1.html&lt;/option&gt;<br />
&lt;option value=&#8221;2.html&#8221;&gt;2.html&lt;/option&gt;<br />
&lt;option value=&#8221;3.html&#8221;&gt;3.html&lt;/option&gt;<br />
&lt;/body&gt;<br />
&lt;html&gt;</p>
<p>  通过测试，可以实现我上面所说的内容，你可以通过<a href="http://down.qiannao.com/space/show/yzlun/%E4%B8%8A%E4%BC%A0%E5%88%86%E4%BA%AB/computerscience/javascript/selecttowindow.html/.page" target="_blank">这里来获取该源文件</a>。</p>


<p>相关文章:<ol><li><a href='http://www.ecoviews.cn/archives/871.html' rel='bookmark' title='Permanent Link: !document.getElementById等的说明！'>!document.getElementById等的说明！</a></li>
<li><a href='http://www.ecoviews.cn/archives/309.html' rel='bookmark' title='Permanent Link: window.location与window.location.href'>window.location与window.location.href</a></li>
<li><a href='http://www.ecoviews.cn/archives/463.html' rel='bookmark' title='Permanent Link: 网站中超链接嵌套！'>网站中超链接嵌套！</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ecoviews.cn/archives/107.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

