<?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.boluor.com/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.boluor.com</link>
	<description></description>
	<lastBuildDate>Fri, 07 Oct 2011 07:28:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>云输入法chrome扩展</title>
		<link>http://www.boluor.com/%e4%ba%91%e8%be%93%e5%85%a5%e6%b3%95chrome%e6%89%a9%e5%b1%95.html</link>
		<comments>http://www.boluor.com/%e4%ba%91%e8%be%93%e5%85%a5%e6%b3%95chrome%e6%89%a9%e5%b1%95.html#comments</comments>
		<pubDate>Thu, 17 Jun 2010 18:37:48 +0000</pubDate>
		<dc:creator>boluor</dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.boluor.com/?p=644</guid>
		<description><![CDATA[<p>在linux下，我在google chrome dev下用ibus输入法，经常出现输入焦点莫名丢失，而且webqq聊天时，用enter和ctrl+enter发送消息经常没效果，偶尔可以。这个时候用qq云输入法或者sougou云输入法就很不错。sougou云输入法已有firefox插件，不必要每次都点击书签中的“启动sougou云输入法”来开启。于是想写个chrome下的扩展，每个页面载入完成后开启qq云输入法(qq的比souguo的快点，不过扩展的写法一样)。</p>
<p>看了一晚上Google Chrome Extensions的文档，发现实现基本的功能还是蛮简单的。利用manifest.json中的conte&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>在linux下，我在google chrome dev下用ibus输入法，经常出现输入焦点莫名丢失，而且webqq聊天时，用enter和ctrl+enter发送消息经常没效果，偶尔可以。这个时候用qq云输入法或者sougou云输入法就很不错。sougou云输入法已有firefox插件，不必要每次都点击书签中的“启动sougou云输入法”来开启。于是想写个chrome下的扩展，每个页面载入完成后开启qq云输入法(qq的比souguo的快点，不过扩展的写法一样)。</p>
<p>看了一晚上Google Chrome Extensions的文档，发现实现基本的功能还是蛮简单的。利用manifest.json中的content_scripts，可以设置每个页面都包含的javascript。示意如下：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:Courier new,verdana;"><span style="color: #009900;">&#123;</span>
<span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;qqCloudIMEforchrome&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;version&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;1.0&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;description&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;a chrome extension that Automatically open qq Colud IME&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;browser_action&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">&quot;default_icon&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;icon.png&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;content_scripts&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>
	<span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">&quot;matches&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://*/*&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">&quot;js&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;qqime.js&quot;</span><span style="color: #009900;">&#93;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>开启QQ的云输入法的一段js代码，也就是qqime.js的内容：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:Courier new,verdana;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>q<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #339933;">!!</span> q <span style="color: #339933;">?</span> q.<span style="color: #660066;">toggle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>d<span style="color: #339933;">,</span> j<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        j <span style="color: #339933;">=</span> d.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        j.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://ime.qq.com/fcgi-bin/getjs'</span><span style="color: #339933;">;</span>
        j.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ime-cfg'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'lt=2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        d.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">QQWebIME</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>如图：<br />
<div id="attachment_647" class="wp-caption alignnone" style="width: 599px"><a href="http://www.boluor.com/wp-content/uploads/2010/06/doodle.png"><img class="size-full wp-image-647" title="qqCloudIME extension" src="http://www.boluor.com/wp-content/uploads/2010/06/doodle.png" alt="qqCloudIME extension" width="589" height="116" /></a><p class="wp-caption-text">qqCloudIME extension</p></div></p>
<p>想试用，可以打开google chrome的开发人员扩展模式。建个文件夹，然后将上述两个文件放置进去，再找个最大19*19像素的icon。打个包提供下载，解压后，选择用chrome打开安装即可。<a href="http://www.boluor.com/wp-content/uploads/2010/06/ChromeExtqqCloudIME.crx_.zip">ChromeExtqqCloudIME.crx</a></p>
<p>现在测试可用，在每次打开一个新页面时会自动打开qq云输入法。不过还有些问题没有解决，比如这个扩展没有提供在当前页面关闭和开启输入法的功能，待完善。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boluor.com/%e4%ba%91%e8%be%93%e5%85%a5%e6%b3%95chrome%e6%89%a9%e5%b1%95.html/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>wordpress纠结笔记之评论表情</title>
		<link>http://www.boluor.com/note-about-wordpress-comment-smiles.html</link>
		<comments>http://www.boluor.com/note-about-wordpress-comment-smiles.html#comments</comments>
		<pubDate>Tue, 18 Aug 2009 09:17:30 +0000</pubDate>
		<dc:creator>boluor</dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.boluor.com/?p=278</guid>
		<description><![CDATA[<p>　　之前在life-studio的BLOG上看到一篇文章介绍<a href="http://wange.im/expression-without-plugins-in-wordpress.html">WordPress 非插件调用表情符</a>.按照其中的提示修改后，发现我还是用不了表情符号。而且很奇怪的是，他的代码中只有如何将显示的表情符号转换为相应的文字符号，没有代码处理将文字符号转换为图片。后来问了才知道，原来wordpress又有默认的处理，将一堆的表情符号转换为相应的图片，不用我们另写代码处理。</p>
<p>　　继续测试，发现显示出来还是文字符号。郁闷，决定自己写代码实现。</p>
<p>　　学了几天正则表达式后，我决定在评论提交到服务器后将这些文字符号替换成相应的图片标签。wordpress的评论提交到了根目录下的wp-comments-post.php中，&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>　　之前在life-studio的BLOG上看到一篇文章介绍<a href="http://wange.im/expression-without-plugins-in-wordpress.html">WordPress 非插件调用表情符</a>.按照其中的提示修改后，发现我还是用不了表情符号。而且很奇怪的是，他的代码中只有如何将显示的表情符号转换为相应的文字符号，没有代码处理将文字符号转换为图片。后来问了才知道，原来wordpress又有默认的处理，将一堆的表情符号转换为相应的图片，不用我们另写代码处理。</p>
<p>　　继续测试，发现显示出来还是文字符号。郁闷，决定自己写代码实现。</p>
<p>　　学了几天正则表达式后，我决定在评论提交到服务器后将这些文字符号替换成相应的图片标签。wordpress的评论提交到了根目录下的wp-comments-post.php中，所以在这里面改。找到</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:Courier new,verdana;"><span style="color: #000088;">$comment_content</span>  <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'comment'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'comment'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>这行代码，在其下面添加几行：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:Courier new,verdana;"><span style="color: #000088;">$baseurl</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/:(.+):/U&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$replacement</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;img src=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$baseurl</span>/wp-contents/images/smilies/icon_<span style="color: #000099; font-weight: bold;">\$</span>{1}.gif<span style="color: #000099; font-weight: bold;">\&quot;</span> alt=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\$</span>{1}<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$comment_content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$replacement</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$comment_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>　　这样处理的话，用life-studio提供的方法，需要修改下他提供的那个文件。smiley.php。（需要下载的看文章末尾的附件）。就是将其中一些wp可以识别的略写的符号都变成了全称，比如:?:换成了:question:。<br />
<span id="more-278"></span><br />
　　继续测试，我只写了几个表情符号的标签，发现可以显示表情图片了。后来，Sandy发现如果评论中有中文就不能显示了，表情符号直接被过滤掉了。life-studio提醒说，可能是wp-comments-post.php不是utf-8格式的，于是再次将其保存为utf-8。这次我写的评论中有中文字符也没问题了。但是Sandy说他发还是没效果。</p>
<p>　　纠结。。。</p>
<p>　　Sandy说貌似只有你有特权吧，其他人都不能使用表情符号。我就去查，果真如此，wordpress又默认将一些标签给屏蔽了，除管理员以外都不能使用。于是，跑到wp-includes/kses.php中，找到$allowedtags，添加img标签：(a标签默认是允许的)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:Courier new,verdana;"><span style="color: #0000ff;">'a'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'href'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'img'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'src'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'alt'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span>	<span style="color: #666666; font-style: italic;">//如果需要更多的属性，在这里添加就可以.</span></pre></td></tr></table></div>

<p>　　也就是说，wordpress是可以定制哪些标签被允许使用的。不过wordpress偷偷作的事情好多好多阿，让我忙乎了差不多一天。</p>
<p><strong>后记：</strong><br />
　　终于搞定了，很无聊，于是随手点击了一个链接进去，突然发现。。。在wordpress设置选项－>撰写栏下面，有个格式化选项，第一个选项就是：转换如 <img src='http://www.boluor.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  和 <img src='http://www.boluor.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' />  的文字表情符号为图像，我没有打勾。。。囧阿。之前以为是一些插件的原因，还一个个的停掉测试了。</p>
<p>　　这一番纠结，虽然学了些东西。不过，我更应该考虑的是Sandy的建议了，wordpress其实并不适合我，它不能让我学到一个博客的底层，太复杂太庞大，我学到的不过是wp的结构和一大堆它提供的函数库罢了，而对于我学html,php,mysql等等，并没有大的提升。其实一个小博客，一个不完善，不牛X的博客才更适合我用。</p>
<p><em>下载附件看这里：</em><br />
<a href='http://www.boluor.com/wp-content/uploads/2009/08/smiley.php.zip'>smiley.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.boluor.com/note-about-wordpress-comment-smiles.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>[临时]测试codeHilight</title>
		<link>http://www.boluor.com/temptesting-codehilight.html</link>
		<comments>http://www.boluor.com/temptesting-codehilight.html#comments</comments>
		<pubDate>Wed, 05 Aug 2009 17:11:29 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.boluor.com/?p=231</guid>
		<description><![CDATA[测试codeHilighter啦～]]></description>
			<content:encoded><![CDATA[<p><b>测试代码喽：</b><br />
<br/>codeHilighter by sandy_zc_1 。<br/>应boluor要求拿来替换掉该死的奇慢无比臃肿不堪的syntaxhighlighter。<br/><br />
<script language="javascript" src="http://www.boluor.com/wp-content/plugins/codeh1/codeh.js" type="text/javascript"></script><br />
<script language="javascript" src="http://www.boluor.com/wp-content/plugins/codeh1/chcommon.js" type="text/javascript"></script></p>
<link rel="stylesheet" href="http://www.boluor.com/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/shCore.css" type="text/css" media="screen" />
<p><b>JS代码：</b></p>
<div id="cdh_js1" class="dCodeH1">
function Space(n)<br/>{<br/>&nbsp;&nbsp;&nbsp; if(n&gt;3)<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; var str1=Space3(Math.floor(n/2));<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; str1+=str1;<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(n%2!=0){ return str1+&quot; &quot;;}<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else { return str1;}<br/>&nbsp;&nbsp;&nbsp; }else if(n==3)<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return &quot; &nbsp; &quot;;<br/>&nbsp;&nbsp;&nbsp; }else if(n==2)<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return &quot; &nbsp;&quot;;<br/>&nbsp;&nbsp;&nbsp; }<br/>&nbsp;&nbsp;&nbsp; return &quot; &quot;;<br/>}
</div>
<p><script language="javascript" >CodeHilight(document.getElementById("cdh_js1"),"JS");</script><br />
<span id="more-231"></span><br />
<b>C++代码：</b></p>
<div id="cdh_cpp1" class="dCodeH1">
// Vector implementation (out of line) -*- C++ -*-<br/><br/>// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.<br/>//<br/>// This file is part of the GNU ISO C++ Library. &nbsp;This library is free<br/>// software; you can redistribute it and/or modify it under the<br/>// terms of the GNU General Public License as published by the<br/>// Free Software Foundation; either version 2, or (at your option)<br/>// any later version.<br/><br/>// This library is distributed in the hope that it will be useful,<br/>// but WITHOUT ANY WARRANTY; without even the implied warranty of<br/>// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. &nbsp;See the<br/>// GNU General Public License for more details.<br/><br/>// You should have received a copy of the GNU General Public License along<br/>// with this library; see the file COPYING. &nbsp;If not, write to the Free<br/>// Software Foundation, 59 Temple Place &#8211; Suite 330, Boston, MA 02111-1307,<br/>// USA.<br/><br/>// As a special exception, you may use this file as part of a free software<br/>// library without restriction. &nbsp;Specifically, if other files instantiate<br/>// templates or use macros or inline functions from this file, or you compile<br/>// this file and link it with other files to produce an executable, this<br/>// file does not by itself cause the resulting executable to be covered by<br/>// the GNU General Public License. &nbsp;This exception does not however<br/>// invalidate any other reasons why the executable file might be covered by<br/>// the GNU General Public License.<br/><br/>/*<br/>&nbsp;*<br/>&nbsp;* Copyright (c) 1994<br/>&nbsp;* Hewlett-Packard Company<br/>&nbsp;*<br/>&nbsp;* Permission to use, copy, modify, distribute and sell this software<br/>&nbsp;* and its documentation for any purpose is hereby granted without fee,<br/>&nbsp;* provided that the above copyright notice appear in all copies and<br/>&nbsp;* that both that copyright notice and this permission notice appear<br/>&nbsp;* in supporting documentation. &nbsp;Hewlett-Packard Company makes no<br/>&nbsp;* representations about the suitability of this software for any<br/>&nbsp;* purpose. &nbsp;It is provided &quot;as is&quot; without express or implied warranty.<br/>&nbsp;*<br/>&nbsp;*<br/>&nbsp;* Copyright (c) 1996<br/>&nbsp;* Silicon Graphics Computer Systems, Inc.<br/>&nbsp;*<br/>&nbsp;* Permission to use, copy, modify, distribute and sell this software<br/>&nbsp;* and its documentation for any purpose is hereby granted without fee,<br/>&nbsp;* provided that the above copyright notice appear in all copies and<br/>&nbsp;* that both that copyright notice and this permission notice appear<br/>&nbsp;* in supporting documentation. &nbsp;Silicon Graphics makes no<br/>&nbsp;* representations about the suitability of this &nbsp;software for any<br/>&nbsp;* purpose. &nbsp;It is provided &quot;as is&quot; without express or implied warranty.<br/>&nbsp;*/<br/><br/>/** @file vector.tcc<br/>&nbsp;* &nbsp;This is an internal header file, included by other library headers.<br/>&nbsp;* &nbsp;You should not attempt to use it directly.<br/>&nbsp;*/<br/><br/>#ifndef _VECTOR_TCC<br/>#define _VECTOR_TCC 1<br/><br/>namespace _GLIBCXX_STD<br/>{<br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt;<br/>&nbsp;&nbsp; &nbsp;void<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;reserve(size_type __n)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;if (__n &gt; this-&gt;max_size())<br/>&nbsp;&nbsp;&nbsp; __throw_length_error(__N(&quot;vector::reserve&quot;));<br/>&nbsp;&nbsp; &nbsp; &nbsp;if (this-&gt;capacity() &lt; __n)<br/>&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp; &nbsp; const size_type __old_size = size();<br/>&nbsp;&nbsp;&nbsp; &nbsp; pointer __tmp = _M_allocate_and_copy(__n,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_start,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp;&nbsp; &nbsp; std::_Destroy(this-&gt;_M_impl._M_start, this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp;&nbsp; &nbsp; _M_deallocate(this-&gt;_M_impl._M_start,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this-&gt;_M_impl._M_end_of_storage &#8211; this-&gt;_M_impl._M_start);<br/>&nbsp;&nbsp;&nbsp; &nbsp; this-&gt;_M_impl._M_start = __tmp;<br/>&nbsp;&nbsp;&nbsp; &nbsp; this-&gt;_M_impl._M_finish = __tmp + __old_size;<br/>&nbsp;&nbsp;&nbsp; &nbsp; this-&gt;_M_impl._M_end_of_storage = this-&gt;_M_impl._M_start + __n;<br/>&nbsp;&nbsp;&nbsp; }<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt;<br/>&nbsp;&nbsp; &nbsp;typename vector&lt;_Tp,_Alloc&gt;::iterator<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;insert(iterator __position, const value_type&amp; __x)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;size_type __n = __position &#8211; begin();<br/>&nbsp;&nbsp; &nbsp; &nbsp;if (this-&gt;_M_impl._M_finish != this-&gt;_M_impl._M_end_of_storage &amp;&amp; __position == end())<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::_Construct(this-&gt;_M_impl._M_finish, __x);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;++this-&gt;_M_impl._M_finish;<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp;else<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;_M_insert_aux(__position, __x);<br/>&nbsp;&nbsp; &nbsp; &nbsp;return begin() + __n;<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt;<br/>&nbsp;&nbsp; &nbsp;typename vector&lt;_Tp,_Alloc&gt;::iterator<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;erase(iterator __position)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;if (__position + 1 != end())<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::copy(__position + 1, end(), __position);<br/>&nbsp;&nbsp; &nbsp; &nbsp;&#8211;this-&gt;_M_impl._M_finish;<br/>&nbsp;&nbsp; &nbsp; &nbsp;std::_Destroy(this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp;return __position;<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt;<br/>&nbsp;&nbsp; &nbsp;typename vector&lt;_Tp,_Alloc&gt;::iterator<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;erase(iterator __first, iterator __last)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;iterator __i(copy(__last, end(), __first));<br/>&nbsp;&nbsp; &nbsp; &nbsp;std::_Destroy(__i, end());<br/>&nbsp;&nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish = this-&gt;_M_impl._M_finish &#8211; (__last &#8211; __first);<br/>&nbsp;&nbsp; &nbsp; &nbsp;return __first;<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt;<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;&amp;<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;operator=(const vector&lt;_Tp,_Alloc&gt;&amp; __x)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;if (&amp;__x != this)<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;const size_type __xlen = __x.size();<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (__xlen &gt; capacity())<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end());<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::_Destroy(this-&gt;_M_impl._M_start, this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_M_deallocate(this-&gt;_M_impl._M_start,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this-&gt;_M_impl._M_end_of_storage &#8211; this-&gt;_M_impl._M_start);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_start = __tmp;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_end_of_storage = this-&gt;_M_impl._M_start + __xlen;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else if (size() &gt;= __xlen)<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iterator __i(copy(__x.begin(), __x.end(), begin()));<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::_Destroy(__i, end());<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::copy(__x.begin(), __x.begin() + size(), this-&gt;_M_impl._M_start);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::uninitialized_copy(__x.begin() + size(), __x.end(), this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish = this-&gt;_M_impl._M_start + __xlen;<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp;return *this;<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt;<br/>&nbsp;&nbsp; &nbsp;void<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;_M_fill_assign(size_t __n, const value_type&amp; __val)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;if (__n &gt; capacity())<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;vector __tmp(__n, __val, get_allocator());<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;__tmp.swap(*this);<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp;else if (__n &gt; size())<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::fill(begin(), end(), __val);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish<br/>&nbsp;&nbsp;&nbsp; &nbsp; = std::uninitialized_fill_n(this-&gt;_M_impl._M_finish, __n &#8211; size(), __val);<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp;else<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;erase(fill_n(begin(), __n, __val), end());<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt; template&lt;typename _InputIterator&gt;<br/>&nbsp;&nbsp; &nbsp;void<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;_M_assign_aux(_InputIterator __first, _InputIterator __last, input_iterator_tag)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;iterator __cur(begin());<br/>&nbsp;&nbsp; &nbsp; &nbsp;for ( ; __first != __last &amp;&amp; __cur != end(); ++__cur, ++__first)<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;*__cur = *__first;<br/>&nbsp;&nbsp; &nbsp; &nbsp;if (__first == __last)<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;erase(__cur, end());<br/>&nbsp;&nbsp; &nbsp; &nbsp;else<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;insert(end(), __first, __last);<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt; template&lt;typename _ForwardIterator&gt;<br/>&nbsp;&nbsp; &nbsp;void<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;forward_iterator_tag)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;size_type __len = std::distance(__first, __last);<br/><br/>&nbsp;&nbsp; &nbsp; &nbsp;if (__len &gt; capacity())<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pointer __tmp(_M_allocate_and_copy(__len, __first, __last));<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::_Destroy(this-&gt;_M_impl._M_start, this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;_M_deallocate(this-&gt;_M_impl._M_start,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;_M_impl._M_end_of_storage &#8211; this-&gt;_M_impl._M_start);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_start = __tmp;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_end_of_storage = this-&gt;_M_impl._M_finish = this-&gt;_M_impl._M_start + __len;<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp;else if (size() &gt;= __len)<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;iterator __new_finish(copy(__first, __last, this-&gt;_M_impl._M_start));<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::_Destroy(__new_finish, end());<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish = __new_finish.base();<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp;else<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;_ForwardIterator __mid = __first;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::advance(__mid, size());<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::copy(__first, __mid, this-&gt;_M_impl._M_start);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish = std::uninitialized_copy(__mid, __last, this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt;<br/>&nbsp;&nbsp; &nbsp;void<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;_M_insert_aux(iterator __position, const _Tp&amp; __x)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;if (this-&gt;_M_impl._M_finish != this-&gt;_M_impl._M_end_of_storage)<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::_Construct(this-&gt;_M_impl._M_finish, *(this-&gt;_M_impl._M_finish &#8211; 1));<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;++this-&gt;_M_impl._M_finish;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;_Tp __x_copy = __x;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::copy_backward(__position,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;iterator(this-&gt;_M_impl._M_finish-2),<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;iterator(this-&gt;_M_impl._M_finish-1));<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;*__position = __x_copy;<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp;else<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;const size_type __old_size = size();<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;const size_type __len = __old_size != 0 ? 2 * __old_size : 1;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;iterator __new_start(this-&gt;_M_allocate(__len));<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;iterator __new_finish(__new_start);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;try<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__new_finish = std::uninitialized_copy(iterator(this-&gt;_M_impl._M_start),<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;__position,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;__new_start);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::_Construct(__new_finish.base(), __x);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;++__new_finish;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__new_finish = std::uninitialized_copy(__position,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;iterator(this-&gt;_M_impl._M_finish),<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;__new_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;catch(&#8230;)<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::_Destroy(__new_start,__new_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_M_deallocate(__new_start.base(),__len);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__throw_exception_again;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::_Destroy(begin(), end());<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;_M_deallocate(this-&gt;_M_impl._M_start,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;_M_impl._M_end_of_storage &#8211; this-&gt;_M_impl._M_start);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_start = __new_start.base();<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish = __new_finish.base();<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_end_of_storage = __new_start.base() + __len;<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt;<br/>&nbsp;&nbsp; &nbsp;void<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;_M_fill_insert(iterator __position, size_type __n, const value_type&amp; __x)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;if (__n != 0)<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (size_type(this-&gt;_M_impl._M_end_of_storage &#8211; this-&gt;_M_impl._M_finish) &gt;= __n)<br/>&nbsp;&nbsp;&nbsp; &nbsp; {<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value_type __x_copy = __x;<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;const size_type __elems_after = end() &#8211; __position;<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;iterator __old_finish(this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;if (__elems_after &gt; __n)<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::uninitialized_copy(this-&gt;_M_impl._M_finish &#8211; __n,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish += __n;<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::copy_backward(__position, __old_finish &#8211; __n, __old_finish);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::fill(__position, __position + __n, __x_copy);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;else<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::uninitialized_fill_n(this-&gt;_M_impl._M_finish,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;__n &#8211; __elems_after,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;__x_copy);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish += __n &#8211; __elems_after;<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::uninitialized_copy(__position, __old_finish, this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish += __elems_after;<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::fill(__position, __old_finish, __x_copy);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp;&nbsp; &nbsp; }<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else<br/>&nbsp;&nbsp;&nbsp; &nbsp; {<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; const size_type __old_size = size();<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; const size_type __len = __old_size + std::max(__old_size, __n);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; iterator __new_start(this-&gt;_M_allocate(__len));<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; iterator __new_finish(__new_start);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; try<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __new_finish = std::uninitialized_copy(begin(), __position,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__new_start);<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __new_finish = std::uninitialized_fill_n(__new_finish, __n, __x);<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __new_finish = std::uninitialized_copy(__position, end(),<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__new_finish);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; catch(&#8230;)<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; std::_Destroy(__new_start,__new_finish);<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; _M_deallocate(__new_start.base(),__len);<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __throw_exception_again;<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; std::_Destroy(this-&gt;_M_impl._M_start, this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; _M_deallocate(this-&gt;_M_impl._M_start,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; this-&gt;_M_impl._M_end_of_storage &#8211; this-&gt;_M_impl._M_start);<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; this-&gt;_M_impl._M_start = __new_start.base();<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; this-&gt;_M_impl._M_finish = __new_finish.base();<br/>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; this-&gt;_M_impl._M_end_of_storage = __new_start.base() + __len;<br/>&nbsp;&nbsp;&nbsp; &nbsp; }<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt; template&lt;typename _InputIterator&gt;<br/>&nbsp;&nbsp; &nbsp;void<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;_M_range_insert(iterator __pos,<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_InputIterator __first, _InputIterator __last,<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input_iterator_tag)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;for ( ; __first != __last; ++__first)<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;__pos = insert(__pos, *__first);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;++__pos;<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp;}<br/><br/>&nbsp;&nbsp;template&lt;typename _Tp, typename _Alloc&gt; template&lt;typename _ForwardIterator&gt;<br/>&nbsp;&nbsp; &nbsp;void<br/>&nbsp;&nbsp; &nbsp;vector&lt;_Tp,_Alloc&gt;::<br/>&nbsp;&nbsp; &nbsp;_M_range_insert(iterator __position,_ForwardIterator __first,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; _ForwardIterator __last, forward_iterator_tag)<br/>&nbsp;&nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp;if (__first != __last)<br/>&nbsp;&nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;size_type __n = std::distance(__first, __last);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (size_type(this-&gt;_M_impl._M_end_of_storage &#8211; this-&gt;_M_impl._M_finish) &gt;= __n)<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const size_type __elems_after = end() &#8211; __position;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iterator __old_finish(this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (__elems_after &gt; __n)<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::uninitialized_copy(this-&gt;_M_impl._M_finish &#8211; __n,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; this-&gt;_M_impl._M_finish,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish += __n;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::copy_backward(__position, __old_finish &#8211; __n, __old_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::copy(__first, __last, __position);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_ForwardIterator __mid = __first;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::advance(__mid, __elems_after);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::uninitialized_copy(__mid, __last, this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish += __n &#8211; __elems_after;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::uninitialized_copy(__position, __old_finish, this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish += __elems_after;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::copy(__first, __mid, __position);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const size_type __old_size = size();<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const size_type __len = __old_size + std::max(__old_size, __n);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iterator __new_start(this-&gt;_M_allocate(__len));<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iterator __new_finish(__new_start);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__new_finish = std::uninitialized_copy(iterator(this-&gt;_M_impl._M_start),<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;__position, __new_start);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__new_finish = std::uninitialized_copy(__first, __last,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;__new_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__new_finish = std::uninitialized_copy(__position,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;iterator(this-&gt;_M_impl._M_finish),<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;__new_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch(&#8230;)<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::_Destroy(__new_start,__new_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_M_deallocate(__new_start.base(), __len);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__throw_exception_again;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::_Destroy(this-&gt;_M_impl._M_start, this-&gt;_M_impl._M_finish);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_M_deallocate(this-&gt;_M_impl._M_start,<br/>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this-&gt;_M_impl._M_end_of_storage &#8211; this-&gt;_M_impl._M_start);<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_start = __new_start.base();<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_finish = __new_finish.base();<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;_M_impl._M_end_of_storage = __new_start.base() + __len;<br/>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp;}<br/>} // namespace std<br/><br/>#endif /* _VECTOR_TCC */<br/><br/>
</div>
<p><script language="javascript" >CodeHilight(document.getElementById("cdh_cpp1"),"CPP");</script><br />
<br/><br />
<br/></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="c" style="font-family:Courier new,verdana;"><span style="color: #993333;">int</span> a<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>↑该死的syntaxhighlighter，还得留个它的小尾巴（因为目前codehilight的css依附于它的css中。。）<br />
(boluor注：现在不需要了，我已经将syntaxhighlighter给禁掉了。在本篇文章中调用了css。)<br />
<br/><br />
<br/><br />
yeah，看来效果还不错。可惜因为还没做成插件，因此使用麻烦些，boluor先将就一下，之后可以将其做成wp插件。<br />
<br/><br />
ok，Sandy收工，boluor，该你上场了～～！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boluor.com/temptesting-codehilight.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>html页面离开时提示</title>
		<link>http://www.boluor.com/html-prompt-when-page-leave.html</link>
		<comments>http://www.boluor.com/html-prompt-when-page-leave.html#comments</comments>
		<pubDate>Mon, 27 Jul 2009 16:10:40 +0000</pubDate>
		<dc:creator>boluor</dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.boluor.com/?p=210</guid>
		<description><![CDATA[<p>    早上用WEBQQ时，离开页面时它提示说：“你确定要离开吗？”好奇这个怎么做出来的。查了些资料，到现在竟然花了一天的时间。<br />
    在IE下实现很简单，因为有个window.event全局变量。在onbeforeunload事件中调用函数，对window.event.returnValue赋值，即可实现。其returnValue有默认值是不可以改变的。</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:Courier new,verdana;"><span style="color: #009900;">&#60;<span style="color: #000000; font-weight: bold;">html</span>&#62;</span>
<span style="color: #009900;">&#60;<span style="color: #000000; font-weight: bold;">head</span>&#62;</span>
<span style="color: #009900;">&#60;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&#34;javascript&#34;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&#34;text/javascript&#34;</span>&#62;</span>
&#160;
function closePrompt(ev</pre></div></div><p>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>    早上用WEBQQ时，离开页面时它提示说：“你确定要离开吗？”好奇这个怎么做出来的。查了些资料，到现在竟然花了一天的时间。<br />
    在IE下实现很简单，因为有个window.event全局变量。在onbeforeunload事件中调用函数，对window.event.returnValue赋值，即可实现。其returnValue有默认值是不可以改变的。</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:Courier new,verdana;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
&nbsp;
function closePrompt(event1)
{
        window.event.returnValue = &quot;navigation leave test&quot;;
}
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> onbeforeunload<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;closePrompt(event)&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.boluor.com&quot;</span>&gt;</span>Click here to navigate to
www.boluor.com<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p><span id="more-210"></span><br />
    但是上述代码在Firefox下却没有出现提示。查了下才知道，firefox并没有window.event这个全局变量。FF在事件触发的时候才会创建event对象。所以上面的closePrompt函数需要修改传参数并且修改为：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:Courier new,verdana;"><span style="color: #003366; font-weight: bold;">function</span> closePrompt<span style="color: #009900;">&#40;</span>event1<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	event1 <span style="color: #339933;">=</span>event1 <span style="color: #339933;">||</span> window.<span style="color: #660066;">event</span><span style="color: #339933;">;</span>    <span style="color: #006600; font-style: italic;">//FF下window.event为空，IE下不传参数所以event1为空。</span>
	event1.<span style="color: #660066;">returnValue</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;navigation leave test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>    这种写法在小程序中没什么，但是如果在一个大程序中，很多事件都需要获得event对象，那这种传来传去的写法就不好了。<br />
    然后去搜索webqq页面源代码，竟然没搜到onbeforeunload和onunload关键字。只好一个个的去把js代码下下来，搜索webqq离开时提示的那句话。终于在main.js中找到了，但是这个又调用了util.js，里面有WEBQQ namespace。。。看不下去了。不过搜到了一款很好的js代码格式化工具Javascript Code Improver ，不用像我第一次研究baidu首页代码时一行一行地对齐了。。。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boluor.com/html-prompt-when-page-leave.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>textContent与innerText的不同</title>
		<link>http://www.boluor.com/differences-between-textcontent-and-einnertext.html</link>
		<comments>http://www.boluor.com/differences-between-textcontent-and-einnertext.html#comments</comments>
		<pubDate>Sat, 20 Jun 2009 16:20:04 +0000</pubDate>
		<dc:creator>Sandy</dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.boluor.com/?p=138</guid>
		<description><![CDATA[<p><strong>textContent与innerText的不同</strong></p>
<p><strong>by  Sandy_zc_1  :</strong>因为发现网络上很少有这方面的内容，因此就把自己私有blog上的这篇文章搬出来到Boluor的公开blog，方便其它人查阅。</p>
<p><strong>————————————————————————————————————————</strong></p>
<p>以下是正文<strong> </strong>↓↓↓<strong> </strong></p>
<p><strong>textContent与innerText的不同</strong></p>
<p>IE下有个innerText属性，FF下有个textContent属性。很多以前给IE写脚本的，在FF下找不到innerText属性，于是网上搜到的建议是用textContent来替代。反之给FF写脚本的也一样。</p>
<p>但是实际上，这里有个误解。网上很多文章说“F&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><strong>textContent与innerText的不同</strong></p>
<p><strong>by  Sandy_zc_1  :</strong>因为发现网络上很少有这方面的内容，因此就把自己私有blog上的这篇文章搬出来到Boluor的公开blog，方便其它人查阅。</p>
<p><strong>————————————————————————————————————————</strong></p>
<p>以下是正文<strong> </strong>↓↓↓<strong> </strong></p>
<p><strong>textContent与innerText的不同</strong></p>
<p>IE下有个innerText属性，FF下有个textContent属性。很多以前给IE写脚本的，在FF下找不到innerText属性，于是网上搜到的建议是用textContent来替代。反之给FF写脚本的也一样。</p>
<p>但是实际上，这里有个误解。网上很多文章说“FF下等效于innerText属性的属性是textContent”————但是事实上并非如此。innerText与textContent有几点很重要的不同，导致它们在一些情况下不能直接互换使用。</p>
<p>前些日子写了个代码高亮JS插件，在IE下工作完全正常，而在FF下就不对头。在IE下使用的是innerText属性，而在FF下使用的则是textContent属性。在进行字符串处理的时候二者的不同导致了完全不一样的结果。于是就专门写了点东西来测试二者的不同。</p>
<p>根据测试的结果表明：<br />
<strong>innerText：</strong>它的内容实际上就是你在浏览器看到的内容。它的值是经过浏览器解释过的结果：它将元素的innerHTML换码、解释，最终显示出来，然后去除各种格式信息留下的纯文本。它会把&lt;br/&gt;换成换行符，会将多个空格并成一个空格对待，而本来的换行符却并不会引起换行，IE会将其当作一个普通的单词边界（一般是空格）。再说的形象点，一个元素的innerText属性的值，和你将这个元素内容复制粘贴到记事本里的内容一致。<span id="more-138"></span></p>
<p><strong>textContent：</strong>它的内容则是innerHTML去除所有标签后的内容（我怀疑这个是从XMLDOM中照搬过来的属性，特性完全一致）。它会将innerHTML中的转义字符（&amp;lt;、&amp;nbsp;什么的）进行换码，但是不对任何html标签进行解释，而是直接剔除它们。它也不会对innerHTML中的文本按照HTML的方式进行格式转换，比如多个空格还会原原本本地保留，不会合并为一个空格，换行符仍然存在（相反&lt;br/&gt;却不会导致换行）。</p>
<p><span style="color: navy;">更加简练的总结：IE中的innerText是需要对innerHTML的值进行：<br />
1、HTML转义（等同于XML转义，对&amp;lt;、&amp;amp;等转义字符进行处理）；<br />
2、经过HTML解释和CSS样式解释；<br />
3、之后又剔除格式信息<br />
之后留下的纯文本。<br />
而FF中的textContent没有2、3步，在经过了HTML转义之后直接剔除所有html标签后得到的纯文本。</span></p>
<p>一个例子：</p>
<blockquote><p>&lt;div id=”T1&#8243;&gt;<br />
ABCD<br />
EFG   HIJ&lt;br/&gt;KLM &amp;nbsp;N<br />
OPQ&lt;div&gt;RS&lt;/div&gt;T<br />
T<br />
&lt;div&gt;</p></blockquote>
<p>这个id为T1的div，<br />
在<span style="color: blue;">IE中的innerText属性</span>的值为：</p>
<blockquote><p>ABCD EFG HIJ<br />
KLM  N OPQ<br />
RS<br />
T T</p></blockquote>
<p>而<span style="color: blue;">在FF中的textContent的属性</span>的值为：</p>
<blockquote>
<div><span style="color: teal;"><em>(这里有个换行)</em></span><br />
ABCD<br />
EFG   HIJKLM  N<br />
OPQRST<br />
T</div>
</blockquote>
<div>注意那个div中还嵌套了个div，而这个更能反映IE的innerText和FF的textContent各自的处理方式的不同：<br />
div是块（block）元素，默认会独占一行，因此，在IE中的innerText反映为上述div中的RS独占一行，而FF的textContent完全不理会HTML格式，因此其textContent中的RS是和其它字符连在一起的，不会独占一行。</p>
<p>.</p>
<p>如果想更进一步，看看这个有趣的结果：<br />
假如给里面那个div加一个style=”float:left;”，那么这个div就会由块元素变化为行元素，不再独占一行，因此IE的innerText属性中RS便不再独占一行，而与其它字符连在一起，而在FF中由于textContent不理会标签更不会理会CSS，因此它的textContent属性的值不会有任何变化。</p>
<p>.</p>
<p>这么看来，很多网上说的“让FF支持innerText属性”云云，其实都是多多少少有问题的。要实现IE的innerText，远没有想象中的那么简单，你若要使用JavaScript让FF拥有和innerText完全一样的效果，得自己把html标签属性全部parse一遍，解释它们，甚至还需要去解释css……<br />
（不过根据原理，貌似通过剪贴板的复制和取回操作可以在FF下模拟innerText效果（这个未测试），但是1有副作用，2FF下的剪贴板操作也很麻烦。）</p>
<p>不过还好，大多数时候我们并不需要那么精确，使用innerHTML做点简单的处理即可达到比较接近的效果了。</p></div>
<p><em>注：以上代码均在IE6和FF3下完成测试。</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.boluor.com/differences-between-textcontent-and-einnertext.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>php+mysql+ajax实现留言本</title>
		<link>http://www.boluor.com/php-mysql-ajax-guestbook.html</link>
		<comments>http://www.boluor.com/php-mysql-ajax-guestbook.html#comments</comments>
		<pubDate>Fri, 08 May 2009 00:34:47 +0000</pubDate>
		<dc:creator>boluor</dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.boluor.com/blog/?p=34</guid>
		<description><![CDATA[<p>Php+mysql+ajax 实现留言本</p>
<p>闲着无聊，写了个简易的留言本，写下总结吧。</p>
<p>留言本的逻辑很简单，在浏览时将所有的留言显示出来，当用户点击提交新的留言时，将其保存到数据库中。如果不用ajax，那每次更新页面都需要刷新页面，而且需要从服务器将所有的数据down下来，一个增大了服务器的压力，二个给用户很不好的使用体验。所以用ajax来实现异步提交，而且新增的页面上提交的内容，也不需要再从服务器上再down下来，直接更新局部页面即可。</p>
<p>wordpress这个编辑器真是垃圾啊,每次修改code的时候,整个就乱了.代码的缩进就全没了。经过几次折腾后,还是决定提供下载吧&#8230;</p>
<p><a href="http://www.boluor.com/wp-content/uploads/2009/05/phpmysqlajaxe79599e8a880e69cac.rar">php+mysql+a</a>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Php+mysql+ajax 实现留言本</p>
<p>闲着无聊，写了个简易的留言本，写下总结吧。</p>
<p>留言本的逻辑很简单，在浏览时将所有的留言显示出来，当用户点击提交新的留言时，将其保存到数据库中。如果不用ajax，那每次更新页面都需要刷新页面，而且需要从服务器将所有的数据down下来，一个增大了服务器的压力，二个给用户很不好的使用体验。所以用ajax来实现异步提交，而且新增的页面上提交的内容，也不需要再从服务器上再down下来，直接更新局部页面即可。</p>
<p>wordpress这个编辑器真是垃圾啊,每次修改code的时候,整个就乱了.代码的缩进就全没了。经过几次折腾后,还是决定提供下载吧&#8230;</p>
<p><a href="http://www.boluor.com/wp-content/uploads/2009/05/phpmysqlajaxe79599e8a880e69cac.rar">php+mysql+ajax留言本</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.boluor.com/php-mysql-ajax-guestbook.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

