﻿<?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; chrome</title>
	<atom:link href="https://www.softwareace.cn/?cat=13&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>https://www.softwareace.cn</link>
	<description>时刻想着为自己的产品多做一些对他好的事情</description>
	<lastBuildDate>Fri, 20 Mar 2026 06:58:28 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>NPAPI和PPAPI开发</title>
		<link>https://www.softwareace.cn/?p=1435</link>
		<comments>https://www.softwareace.cn/?p=1435#comments</comments>
		<pubDate>Wed, 17 Feb 2016 06:13:36 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[chrome]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=1435</guid>
		<description><![CDATA[http://blog.csdn.net/lee353086/article/details/49302917 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>http://blog.csdn.net/lee353086/article/details/49302917</p>
<h1>NPAPI和PPAPI开发</h1>
<p>Author: kagula</p>
<p>Revison: 1<br />
Last modify date：2015-10-20</p>
<h2><a style="color: #336699;" name="t1"></a><strong>环境：</strong></h2>
<p>[1]Visual Studio 2010 SP1<br />
Visaul Stuio  2013 Update4<br />
[2]Python2.7<br />
[3]Firefox 41.0.1<br />
[4]IE 11<br />
[5]Google chrome 45.0.2454.101<br />
[6]Opera 32.0<br />
[7]360浏览器 7.1.1.808<br />
[8]nacl sdk pepper39<br />
[9]windows7 SP1 64bits</p>
<h2><a style="color: #336699;" name="t2"></a><strong>关键词</strong></h2>
<p>Firebreath, NPAPI, PPAPI, Web worker, Messaging System, Native Client Module, Application Structure<br />
Chrome Web Store, portable executable file, architecture-specific executable file</p>
<h2><a style="color: #336699;" name="t3"></a><strong>前言 </strong></h2>
<p>如果要实现Windows平台，跨不同浏览器插件，就需要分别实现<br />
ActiveX  适用浏览器IE11，因为IE11对FireBreath兼容性不是很好。<br />
FreBreath(NPAPI)  适用浏览器,360浏览器，Chrome 42版本以下，Opera、Firefox。<br />
NaCl(可分为PPAPI、NaCl、PNaCl三个等级) 适用浏览器Chrome 42版本或以上。<br />
ActiveX的baidu上很多，但是NPAPI和PPAPI的很不完善，所以这里仅仅介绍NPAPI和PPAPI的开发。<br />
<img src="http://img.blog.csdn.net/20151026090949743" alt="" /></p>
<h2><a style="color: #336699;" name="t4"></a><strong>第一部份：NPAPI</strong></h2>
<p><strong>第一个插件(NPAPI)：</strong><br />
firebreath是个跨浏览器插件开发工具，所以先尝试FireBreath。<br />
<strong>Step1:</strong><br />
参考资料[3]下载firebreath最新稳定版本，并解压到“D:\SDK\firebreath-FireBreath-105dcc6\”目录下<br />
从官网上下载firebreath-boost-1.50.0.zip<br />
位置参考下面摆放：<br />
&lt;FB_ROOT&gt;/src/3rdParty/boost/boost/<br />
&lt;FB_ROOT&gt;/src/3rdParty/boost/libs/</p>
<p><strong>Step2</strong>:先建一个Hello工程。<br />
打开控制台，切换到“D:\SDK\firebreath-FireBreath-105dcc6”文件夹，<br />
输入命令“python fbgen.py”根据提示输入你第一个工程plugin name,plugin description,company name等信息。<br />
命令执行完毕后，再调用“prep2010.cmd”命令。<br />
python就在当前build子目录下建好了VS2010 solution，FireBreath.sln文件。<br />
打开sln后应该就能正确编译。如果有问题参考资料[1]。</p>
<p><strong>Step3</strong>:测试插件是否正确加载。<br />
[S3-1]IE下运行插件。<br />
命令行方式转到“D:\SDK\firebreath-FireBreath-105dcc6\build\bin\hello\Debug”路径下，使用“regsvr32 nphello.dll”注册控件。<br />
&#8220;D:\SDK\firebreath-FireBreath-105dcc6\build\projects\hello\gen&#8221;路径下打开“FBControl.htm”文件，就可以在IE中正常运行hello控件。<br />
如果有问题，参考资料[2]。<br />
[S3-2]Firefox下运行插件<br />
我是把dll复制到“C:\Users\kagula\AppData\Roaming\Mozilla\Firefox\Profiles\ie1ypj6h.default\plugins”路径就Ok了，如果没有“plugins”目录就新建一个。<br />
不同的计算机Win7下，参考下面的格式就Ok了。<br />
“C:\Users\XXX\AppData\Roaming\Mozilla\Firefox\Profiles\XXX.default\plugins”<br />
[S3-3]Chrome下运行<br />
Chrome 45 不支持NPAPI。<br />
[S3-4]Opera下运行<br />
使用“regsvr32 nphello.dll”注册控件后，可以直接使用，<br />
但是会提示“此网站使用的插件很快将不被支持”<br />
[S3-5]360浏览器下运行<br />
使用“regsvr32 nphello.dll”注册控件后，可以直接使用，</p>
<p><strong>Step4</strong>:测试插件功能是否正常<br />
[1]hello.cpp的FB::JSAPIPtr hello::createJSAPI()函数，创建了helloAPI实例返回。<br />
查看helloAPI实现，<br />
echo方法用来示例参数传递，testEvent方法示例事件回调，testString和version示例如何存取对象的属性。<br />
[2]FBControl.htm文件，点击“Fire a test event”会间接调用helloAPI实例的testEvent方法，这个方法又会激活JS的test事件。<br />
在IE中没有反应，但是在Opera和360浏览器中测试正常。<br />
[3]FBControl.htm文件，点击“Activate click counter”，就多一次对插件echo事件的绑定。<br />
然后，再点击“Click me!”，JS会调用插件的echo方法，而插件的echo方法会调用js对echo事件的绑定function。<br />
在IE中依旧没有反应。<br />
[4]测试插件属性的存取，<br />
[S4-1]为FBControl.htm文件，添加一个js函数。<br />
function testPluginPropertyAccess()<br />
{<br />
alert(plugin().testString);<br />
plugin().testString = &#8220;插件属性的默认值已经被JS修改&#8221;;<br />
alert(plugin().testString);<br />
}<br />
为FBControl.htm文件，添加一个链接，可以让用户点击。<br />
&lt;a href=&#8221;#&#8221; onclick=&#8221;javascript:testPluginPropertyAccess()&#8221;&gt;测试对属性值的修改&lt;/a&gt; &lt;br /&gt;<br />
[S4-2]修改helloAPI.h文件，在helloAPI的构造函数中添加下面的代码。<br />
m_testString = &#8220;Default value in c++&#8221;;<br />
这样我们才能知道这个属性的值是来自C++代码的。<br />
[S4-3]然后再参考上文，测试即可。<br />
[<strong>Step5</strong>]验证是否能自绘区域<br />
一开始在&#8221;hello&#8221;项目上onWindowAttached死活不会来，后来又重建了一个firegbreath项目就好了。<br />
猜测是用fbgen.py新建项目时，输入的参数不对。<br />
下面是我的测试函数，我往plugin api里注册了“draw”函数，用来测试能否绘制html表面。<br />
void helloAPI::draw()<br />
{<br />
if (_wnd) {<br />
HDC hDC = GetDC(_wnd-&gt;getHWND());</p>
<p>RECT rect;<br />
rect.left=0,rect.top=0,rect.right=256,rect.bottom=256;</p>
<p>HBRUSH hbr;<br />
hbr = CreateSolidBrush(RGB(255,0,0));<br />
FillRect(hDC,&amp;rect,hbr);</p>
<p>ReleaseDC(_wnd-&gt;getHWND(),hDC);<br />
}<br />
}</p>
<p>具体参考“&#8230;\firebreath-FireBreath-105dcc6\examples\BasicMediaPlayer”目录下的源代码。</p>
<p>备注<br />
[1]Firebreath缺省没有连接下面两个事件：<br />
EVENTTYPE_CASE(FB::RefreshEvent, draw, FB::PluginWindow);<br />
EVENTTYPE_CASE(FB::WindowsEvent, onWindowEvent, FB::PluginWindow)</p>
<h2><a style="color: #336699;" name="t5"></a>第二部份：PPAPI</h2>
<p>Chrome插件只能使用PPAPI接口的Native Client(NaCl)方式编写，<br />
Native Client分别有三种embed类型<br />
“application/x-ppapi”，平台相关，唯一能直接使用win32 api的platfrom（有功能上的限制）。  dll格式，<br />
不允许通过Chrome web store分发。据说Flash就是采用第一种类型开发的。<br />
“application/x-nacl”， 只能通过PPAPI，平台无关，cpu相关。nexe格式，只能通过Chrome web store分发。<br />
“application/x-pnacl”，只能通过PPAPI，平台无关，cpu无关。pexe格式，可以不通过Chrome web store分发。<br />
为了减少麻烦，建议系统只安装Visual Studo 2010版。</p>
<p>跟着官网先学习第一个PPAPI插件(Native Client)的开发流程<br />
首先参考<br />
《C++ Tutorial: Getting Started 》</p>
<p>https://developer.chrome.com/native-client/devguide/tutorial/tutorial-part1</p>
<p>建立，运行，修改自己的第一个portable native client程序，这样就先有了个概念。<br />
按照tutorial一步步走是没有问题了，但是</p>
<p><strong>如何在VS中开发、调试native client程序？</strong><br />
你需要为nacl sdk安装vs_addin。<br />
官网文档上说vs_addin只支持vs2010sp1和vs2012，但是经过修改能支持vs2013，但是不建议折腾。<br />
<strong>[Step1]</strong>设置当前计算机用户变量<br />
NACL_SDK_ROOT环境变量为“E:\SDK\nacl_sdk\pepper_39”。<br />
CHROME_PATH环境变量为“C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”。<br />
<strong>[Step2]</strong>管理员权限启动控制台转到“E:\SDK\nacl_sdk\vs_addin”路径下，输入“Install”命令安装“vs_addin”。<br />
以后你还可以通过输入“Install  &#8211;uninstall”命令来反安装。<br />
<strong>[FinalStep-PPAPI]</strong>现在可以转到“E:\SDK\nacl_sdk\vs_addin\examples\hello_world_gles”目录，使用VS2010打开hello_world_gles solution。<br />
platform从默认“NaCI32”改为“PPAPI”即可编译通过，会在当前project路径下产生win目录，win目录下会生成hello_world_gles.dll文件。<br />
直接按[F5]就可以Debug這個dll，在VisualStudio中进入断点。<br />
<strong>[FinalStep-NaCl64]</strong>platform从默认“NaCI32”改为“NaCI64”,<br />
project property page should be<br />
[General]-&gt;[Native Client]-&gt;[IndexPage of NaCl Application]-&gt;[index_newlib.html]<br />
[General]-&gt;[Native Client]-&gt;[Toolchain]-&gt;[newlib]<br />
在当前项目NaCl64\newlib\Debug路径下只生成一个hello_world_gles_64.nexe文件，所以调试针对的是这个文件。<br />
由于这个文件是虚拟代码（据说运行前会转成机器码）所以只能用nacl sdk带的gdb来调试。<br />
[F5]启动Debug，默认打开index_newlib.html页面，启动gdb控制台后就可以命令行方式调试了。<br />
你可能需要设置chrome启用NaCl，授权Chrome能够使用未经Chrome Web Store发布的nexe文件。<br />
<strong>[FinalStep-PNaCl]</strong>platform从默认“NaCI32”改为“PNaCl”，会在当前项目下编译输出一个pexe文件和三个针对不同cpu的nexe文件，VS中[F5]不会进入Debug、break模式。</p>
<p>备注：<br />
[1]具体参考官方vs-addin文档。  https://developers.google.com/native-client/dev/devguide/devcycle/vs-addin<br />
[2]在啟動chrome調試前，勾選F12-&gt;Settins-&gt;General-&gt;Disable cache（while DevTools is open）防止html緩存。</p>
<p><strong>如何部署pexe格式控件到chrome上？</strong><br />
[Step1]先检查PNaCI是否在chrome中启用（默认已经安装）<br />
在chrome中addressbar中使用“chrome://nacl/”查看是否允许PNaCI插件。如果没有安装相应component，可以输入“chrome://components”在compoennts页面中安装或更新。<br />
[Step2]假设&#8221;E:\nginx-1.8.0\html&#8221;是你Web服务器的webroot路径，把“E:\SDK\nacl_sdk\pepper_39\getting_started\part1”目录下的<br />
hello_tutorial.nmf和hello_tutorial.pexe两个文件复制到&#8221;E:\nginx-1.8.0\html&#8221;。把“index.html”重命名为“hello_tutorial.html”并复制到webroot路径中。<br />
现在你的webroot路径中已经有了“hello_tutorial.nmf”、“hello_tutorial.pexe”和“hello_tutorial.html”三个文件。<br />
[FinalStep]在chorme中输入“http://localhost:8080/hello_tutorial.html”打开pexe测试页面，测试成功。</p>
<p><strong>如何运行vs_addin自带的hello_nacl_cpp项目？</strong><br />
[Step1]用vs2010打开hello_nacl_cpp项目后，修改好代码后，选择PNaCl平台编译出pexe和nexe文件。<br />
[Step2]在“E:\SDK\nacl_sdk\pepper_39\examples”路径下新建“hello_nacl_cpp”目录。<br />
[Step3]复制“E:\SDK\nacl_sdk\vs_addin\examples\hello_nacl_cpp\hello_nacl_cpp\PNaCl\newlib\Debug”路径下的pexe、nexe扩展名的四个文件<br />
到新建的“E:\SDK\nacl_sdk\pepper_39\examples\hello_nacl_cpp”路径下面。<br />
复制“E:\SDK\nacl_sdk\vs_addin\examples\hello_nacl_cpp\hello_nacl_cpp\index.html”文件到新的路径下。<br />
复制“E:\SDK\nacl_sdk\vs_addin\examples\hello_nacl_cpp\hello_nacl_cpp\PNaCl\hello_nacl_cpp.nmf”文件到新的路径下。<br />
[Step4]修改新路径下的index.html，把embed元素中的type属性从“application/x-nacl”改为“application/x-pnacl”。<br />
因为PNaCl插件mime type只能为“application/x-pnacl”。<br />
修改新路径下的hello_nacl_cpp.nmf文件，使之支持pexe，并能从当前目录读取pexe文件，修改后的内容如下：<br />
{<br />
&#8220;files&#8221;: {},<br />
&#8220;program&#8221;: {<br />
&#8220;portable&#8221;: {<br />
&#8220;pnacl-translate&#8221;: {<br />
&#8220;url&#8221;: &#8220;hello_nacl_cpp.pexe&#8221;<br />
}<br />
},<br />
&#8220;x86-64&#8243;: {<br />
&#8220;url&#8221;: &#8220;hello_nacl_cpp_64.nexe&#8221;<br />
},<br />
&#8220;arm&#8221;: {<br />
&#8220;url&#8221;: &#8220;hello_nacl_cpp_arm.nexe&#8221;<br />
},<br />
&#8220;x86-32&#8243;: {<br />
&#8220;url&#8221;: &#8220;hello_nacl_cpp_32.nexe&#8221;<br />
}<br />
}<br />
}<br />
[FinalStep-PNaCl方式]<br />
在控制台下启动“E:\SDK\nacl_sdk\pepper_39\examples\httpd.cmd”程序。<br />
在chrome中输入“http://localhost:5103/hello_nacl_cpp/”成功打开测试页面。</p>
<p><strong>如何新建NaCl项目</strong><br />
在visual studio中新建C++ Empty Project<br />
設置項目屬性為[General]-&gt;[Project Defaults]-&gt;[Configuration Type]-&gt;[Dynamic Library(.dll)]。<br />
新建好项目后，就可以添加源代码文件开始编程。<br />
这里没有从新的C++ Dll Empty Project开始，是因为这个wizard会引入很多win32定义导致NaCl64平台编译失败，修改起来太麻烦。</p>
<p>示例代码有两种风格，第一种参考“vs_addin\examples”下的hello_nacl_cpp项目，第二种参考“hello_world_gles”项目，<br />
开发包自带的例子基本上都属于这种风格。<br />
典型的代码如下：</p>
<div class="dp-highlighter bg_cpp">
<div class="bar">
<div class="tools" style="color: silver;"><b>[cpp]</b> <a class="ViewSource" style="color: #a0a0a0;" title="view plain" href="http://blog.csdn.net/lee353086/article/details/49302917#">view plain</a><span class="tracking-ad" data-mod="popu_168"><span class="tracking-ad" data-mod="popu_168"> <a class="CopyToClipboard" style="color: #a0a0a0;" title="copy" href="http://blog.csdn.net/lee353086/article/details/49302917#">copy</a></span></span></p>
<div></div>
</div>
</div>
<ol class="dp-cpp" style="color: #5c5c5c;" start="1">
<li class="alt" style="color: inherit;"><span style="color: black;"><span class="preprocessor" style="color: gray;">#include &#8220;ppapi/cpp/instance.h&#8221;</span>  </span></li>
<li><span style="color: black;"><span class="preprocessor" style="color: gray;">#include &#8220;ppapi/cpp/module.h&#8221;</span>  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;"><span class="preprocessor" style="color: gray;">#include &#8220;ppapi/cpp/var.h&#8221;</span>  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;"><span class="keyword" style="font-weight: bold; color: #006699;">class</span> MyInstance : <span class="keyword" style="font-weight: bold; color: #006699;">public</span> pp::Instance {  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;"><span class="keyword" style="font-weight: bold; color: #006699;">public</span>:  </span></li>
<li><span style="color: black;">    <span class="keyword" style="font-weight: bold; color: #006699;">explicit</span> MyInstance(PP_Instance instance) : pp::Instance(instance)  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">    {}  </span></li>
<li><span style="color: black;">    <span class="keyword" style="font-weight: bold; color: #006699;">virtual</span> ~MyInstance() {}  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">    <span class="keyword" style="font-weight: bold; color: #006699;">virtual</span> <span class="keyword" style="font-weight: bold; color: #006699;">void</span> HandleMessage(<span class="keyword" style="font-weight: bold; color: #006699;">const</span> pp::Var&amp; var_message) {  </span></li>
<li><span style="color: black;">        <span class="keyword" style="font-weight: bold; color: #006699;">if</span> (var_message.is_string())  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">        {  </span></li>
<li><span style="color: black;">            std::string message = var_message.AsString();  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">            pp::Var var_reply;  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;">            std::string reply = <span class="string" style="color: blue;">&#8220;echo [&#8220;</span>;  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">            reply.append(message);  </span></li>
<li><span style="color: black;">            reply.append(<span class="string" style="color: blue;">&#8221; from my NaCi module&#8221;</span>);  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">            var_reply = pp::Var(reply);  </span></li>
<li><span style="color: black;">            PostMessage(var_reply);  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">        }  </span></li>
<li><span style="color: black;">    }  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">};  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;"><span class="keyword" style="font-weight: bold; color: #006699;">class</span> MyModule : <span class="keyword" style="font-weight: bold; color: #006699;">public</span> pp::Module {  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;"><span class="keyword" style="font-weight: bold; color: #006699;">public</span>:  </span></li>
<li><span style="color: black;">    MyModule() : pp::Module() {}  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">    <span class="keyword" style="font-weight: bold; color: #006699;">virtual</span> ~MyModule() {}  </span></li>
<li><span style="color: black;">    <span class="keyword" style="font-weight: bold; color: #006699;">virtual</span> pp::Instance* CreateInstance(PP_Instance instance) {  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">        <span class="keyword" style="font-weight: bold; color: #006699;">return</span> <span class="keyword" style="font-weight: bold; color: #006699;">new</span> MyInstance(instance);  </span></li>
<li><span style="color: black;">    }  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">};  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;"><span class="keyword" style="font-weight: bold; color: #006699;">namespace</span> pp {  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">    Module* CreateModule() {  </span></li>
<li><span style="color: black;">        <span class="keyword" style="font-weight: bold; color: #006699;">return</span> <span class="keyword" style="font-weight: bold; color: #006699;">new</span> MyModule();  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">    }  </span></li>
<li><span style="color: black;">}  </span></li>
</ol>
</div>
<p>测试dll、pexe格式的控件用的html和js可以从“hello_world_gles”例子的基础上只要做很小的修改就能测试插件有没有装载成功。<br />
“PPAPI”平台下编译不会fire load事件在html中，导致不会提示成功装载插件的提示，但是实际上“hello_world_gles”插件已经正常运行。<br />
你可能需要修改当前工程的[Configuration Properties]-&gt;[General]-&gt;[Native Client]-&gt;[Index Page of NaCl Application]属性指定html文件名<br />
VS启动Debug的时候会以命令行方式传递给chrome的flags设置。<br />
所以在VS外你要使用nexe文件，需要在Chrome浏览器中输入“chrome://flags/”启用“Native Client”，授权chrome可以使用未经chrome web store发布的native client程序。</p>
<p>备注：<br />
[1]NaCl64启动调试后，在Chrome46中装载控件会失败，导致gdb不能单步跟踪，但是Chrome43没有这个问题。</p>
<p>[参考资料]</p>
<p>https://developer.chrome.com/native-client/devguide/devcycle/debugging</p>
<p>https://developer.chrome.com/native-client/devguide/devcycle/building</p>
<p><strong>如何在vs2013中使用vs2013的native client插件</strong><br />
[Step1] 复制 %user%\Documents\Visual Studio 2012\Addins\ 到 %user%\Documents\Visual Studio 2013\Addins<br />
[Step2] 复制  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\NaCl\  到  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\NaCl\<br />
[FinalStep] 复制 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\ 下的以下文件夹<br />
ARM NaCl32 NaCl64 NaClARM PNaCl PPAPI<br />
到 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Platforms\</p>
<p>C:\Users\kagula\AppData\Local\Google\Chrome\User Data<br />
C:\Program Files (x86)\Google\Chrome\Application</p>
<p><strong>如何重新编译NaCi的ppapi_cpp？</strong><br />
打开Visual Studio Command Prompt然后使用下面的命令：<br />
$ cd $NACL_SDK_ROOT\src\ppapi_cpp<br />
$ make TOOLCHAIN=win CONFIG=Debug<br />
$ make TOOLCHAIN=win CONFIG=Release</p>
<p><strong>NaCl Module如何调用Win32 API？</strong><br />
项目只有在“PPAPI”platform下才能直接调用win32 api，虽然能自由调用win32api,<br />
但是调用win32 api创建新的进程，或调用C++ std对本地磁盘进行操作都会失败！<br />
想要自由的使用win32 api只能参考下面的文档来实现，据说是唯一的解决办法。<br />
《Native Messaging》</p>
<p>https://developer.chrome.com/extensions/nativeMessaging</p>
<p>下面解释了“PPAPI”platform的限制。</p>
<p>http://stackoverflow.com/questions/23472077/purpose-of-ppapi-toolchain-and-how-to-use-it?rq=1</p>
<p><strong>JS如何接收来自Native Client的消息</strong><br />
最简单的例子是..\nacl_sdk\vs_addin\examples\hello_nacl\hello_nacl下的index.html源文件。</p>
<p><strong>常见问题</strong><br />
Q 编译项目提示。<br />
Error 1  error MSB6006: &#8220;C:\sdk\nacl_sdk\pepper_39\toolchain\win_x86_newlib\bin\x86_64-nacl-g++.exe&#8221; exited with code 1.<br />
那是少了依赖库引起的，比如说，如果你用到gles2，添加“ppapi_gles2”依赖库后，问题消失。<br />
Q 在“PPAPI”plaform下提示ppapi_cpp.obj找不到。<br />
修改依赖项从“ppapi_cpp;ppapi;”为“ppapi_cpp.lib;ppapi.lib;”后，重新rebuild即可。<br />
Q 运行“&#8230;\nacl_sdk\pepper_39\examples”下的例子,chrome提示“PnaclCoordinator: Compile process could not be created”</p>
<p>Chrome中输入“chrome://flags/”，停止“Native Client 基于 GDB 的调试 Mac, Windows, Linux, Chrome OS”项即可。</p>
<p>Q遇到sdk下的examples无法装载的例子</p>
<p>Chrome中输入“chrome://components”检查pnacI是否已经安装。</p>
<p><strong>总结</strong><br />
相对于NPAPI，PPAPI开发成本高，运行速度慢，所谓sandbox安全性只不过是始皇上缴天下铁器的强盗逻辑，<br />
唯一的亮点是PPAPI的pexe格式插件可以一处编译处处运行。</p>
<p><strong>备注：</strong><br />
[1]在“&#8230;\nacl_sdk\pepper_39\examples”路径下google提供了大量的example用来帮助开发者学习PPAPI。<br />
参考资料[10]也有大量的pexe例子。</p>
<h2><a style="color: #336699;" name="t6"></a>参考资料</h2>
<p>[1]《跨浏览器插件框架FireBreath安装与使用之一——Windows下的插件》</p>
<p>http://blog.csdn.net/ubuntu64fan/article/details/7941167</p>
<p>[2]《Firebreath插件制作》</p>
<p>http://blog.csdn.net/oldmtn/article/details/46362135</p>
<p>[3]FireBreath Home</p>
<p>http://www.firebreath.org/display/documentation/FireBreath+Home</p>
<p>[4]《firebreath 在谷歌和火狐浏览器下的调试 以及打包》</p>
<p>http://www.cnblogs.com/drzhong/p/firebreath_dubug.html</p>
<p>[5]《Building a firefox plugin – part one》</p>
<p>http://colonelpanic.net/2009/03/building-a-firefox-plugin-part-one/</p>
<p>[6]《Introduction to Portable Native Client》</p>
<p>https://www.chromium.org/nativeclient/pnacl/introduction-to-portable-native-client</p>
<p>[7]《Distributing Your Application》</p>
<p>https://developer.chrome.com/native-client/devguide/distributing</p>
<p>[8]《Problems when develop ppapi plugins in NACL.》</p>
<p>https://groups.google.com/forum/embed/#!topic/native-client-discuss/hihnZnB8k0M</p>
<p>[9]《2DPaintingModel》</p>
<p>https://code.google.com/p/ppapi/wiki/2DPaintingModel</p>
<p>[10]《ppapi example》</p>
<p>https://chromium.googlesource.com/chromium/src/ppapi/+/master/examples</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=1435</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>kindeditor 粘贴网络图片保存到服务器</title>
		<link>https://www.softwareace.cn/?p=1100</link>
		<comments>https://www.softwareace.cn/?p=1100#comments</comments>
		<pubDate>Thu, 08 Jan 2015 05:05:36 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[chrome]]></category>
		<category><![CDATA[kindeditor]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=1100</guid>
		<description><![CDATA[人老了，记忆也衰退了。写代码时，只有思路，具体写起来确总忘这忘那。还有的特性或功能，脑子里朦胧记得曾经看到过或 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>人老了，记忆也衰退了。写代码时，只有思路，具体写起来确总忘这忘那。还有的特性或功能，脑子里朦胧记得曾经看到过或曾经写过却总也记不起来。在网 上找好多人的文章也就是转载别人，而图片因原作者空间失效而失效。于是想在自己blog 在转载好文章备份时，能顺便把里面图片也保存到自己服务器上。</p>
<p>由于对javascript 的了解不够深入，要在一个完全陌生的编辑器上做插件还真有点困难，加上php 也不是常用，边学边做发了三天终于将这样一个 粘贴网络图片保存到服务器 小插件做成功了。</p>
<p>贴出部分代码：</p><pre class="crayon-plain-tag">// 图片另存到服务器
		editor.addContextmenu({
	        title : '另存到服务器',
	        click : function() {
	         var img = getImageFromRange(editor.edit.cmd.range, function(img) {
	        	 	return !/^ke-\w+$/i.test(img[0].className);
	         	});
	         var imgsrc = img.attr('src');
	         K.ajax('./editor/php/saveToServer.php', function(data){var newsrc = K.formatUrl(data.url,'absolute');
	         editor.exec('insertimage', newsrc, '', '', '', '', '');
	         editor.hideMenu();} , 'POST' ,{imgurl:imgsrc});
	        },
	        cond : function() {
	        return getImageFromRange(editor.edit.cmd.range, function(img) {
	            return !/^ke-\w+$/i.test(img[0].className);
	        });
	        }
		});</pre><p>服务器端代码：</p><pre class="crayon-plain-tag">require_once 'JSON.php';
require_once '../../globals.php';
$php_path = ADMIN_ROOT . '/';
$php_url = dirname($_SERVER['PHP_SELF']) . '/../../';
$root_path = $php_path . OPTION::UPLOADFILE_PATH.'image/netimg/';
$root_url = $php_url . OPTION::UPLOADFILE_PATH.'image/netimg/';
set_time_limit(0);
$filepath=urldecode($_POST['imgurl']);
$imgArray=array('.gif','.jpg','.png','.jpeg','.bmp');
$typeArray=array();
ob_start();
$type=strrchr(trim($filepath),".");
$result = false;
if($filepath!='' &amp;&amp; in_array($type,$imgArray))
{
	$now=time();
	$filename=$now.strrchr(trim($filepath),".");
			//$filename=md5_file(trim($files[$i])).strrchr(trim($files[$i]),".");
	$ret = create_folders($root_path);
	if($ret != false){ 
		$savetime=SaveHTTPFile(trim($filepath),$root_path.$filename);
		$result = true;
	}
}
ob_end_flush();
if($result){
		header('Content-type: text/html; charset=UTF-8');
		$json = new Services_JSON();
		echo $json-&gt;encode(array('error' =&gt; 0, 'url' =&gt; $root_url.$filename));
		exit;		
}else{
		alert('创建目录失败！');
}

function getmicrotime(){
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
}

function SaveHTTPFile($fFileHTTPPath,$fFileSavePath)
{
	//记录程序开始的时间
	$BeginTime=getmicrotime();

	//取得文件的内容
	ob_start();
	readfile($fFileHTTPPath);
	$img = ob_get_contents();
	ob_end_clean();
	//$size = strlen($img);

	//保存到本地
	$fp2=@fopen($fFileSavePath, "a");
	fwrite($fp2,$img);
	fclose($fp2);

	//记录程序运行结束的时间
	$EndTime=getmicrotime();

	//返回运行时间
	return($EndTime-$BeginTime);
}</pre><p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=1100</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>kindeditor编辑器高级篇：如何通过监听kindeditor编辑器的粘贴(CTRL+V)事件直接过滤掉复制内容内所有的标签包括超链接</title>
		<link>https://www.softwareace.cn/?p=1098</link>
		<comments>https://www.softwareace.cn/?p=1098#comments</comments>
		<pubDate>Wed, 07 Jan 2015 09:56:33 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[chrome]]></category>
		<category><![CDATA[kindeditor]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=1098</guid>
		<description><![CDATA[昨天写个一篇如何在执行一键清除HTML功能键的同时去掉kindeditor编辑器内容的所有超链接的博客，地址为 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">昨天写个一篇如何在执行一键清除HTML功能键的同时去掉kindeditor编辑器内容的所有超链接的博客，地址为：</span><a style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #3570b3; text-decoration: none; background: transparent;" href="http://www.stepday.com/topic/?688" target="_blank"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">http://www.stepday.com/topic/?688</span></a><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;"> 今天琢磨了一下是否可以更加直接地在粘贴内容至kindeditor编辑器内的时候就清楚HTML标签和去掉所有的超链接，换句话说就是只能够粘贴纯文本进入kindeditor编辑器内。</span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">通过翻看kindeditor-min.js源码文件，查找“<strong style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;">b.pasteType === 1</strong>”关键词，我们看到的代码片段如下所示：</span></p>
<p></p><pre class="crayon-plain-tag">b.pasteType === 1 &amp;&amp; (d = d.replace(/&lt;br[^&gt;]*&gt;/ig, "\n"), d = d.replace(/&lt;\/p&gt;&lt;p[^&gt;]*&gt;/ig, "\n"), d = d.replace(/&lt;[^&gt;]+&gt;/g, ""), d = d.replace(/&amp;nbsp;/ig, " "), d = d.replace(/\n\s*\n/g, "\n"), d = d.replace(/ {2}/g, " &amp;nbsp;"), b.newlineTag == "p" ? /\n/.test(d) &amp;&amp; (d = d.replace(/^/, "&lt;p&gt;").replace(/$/, "&lt;/p&gt;").replace(/\n/g, "&lt;/p&gt;&lt;p&gt;")) : d = d.replace(/\n/g, "&lt;br /&gt;$&amp;")), b.insertHtml(d, !0))</pre><p>&nbsp;</p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">这段代码就是实现了CTRL+V的粘贴功能，获取粘贴板内的内容d，然后对其进行简单性的处理然后赋值给编辑器b。</span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">在这里我们不难发现并未去除过多的HTML代码且清楚超链接，所以我们需要在这里对编辑器对象b做一些后加处理，我们通过b.text()就可以拿到编辑器内的纯文本内容了，然后再将其赋值给编辑器b不就行了么？</span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">所以得到了修改后的代码片段：</span></p>
<p></p><pre class="crayon-plain-tag">b.pasteType === 1 &amp;&amp; (d = d.replace(/&lt;br[^&gt;]*&gt;/ig, "\n"), d = d.replace(/&lt;\/p&gt;&lt;p[^&gt;]*&gt;/ig, "\n"), d = d.replace(/&lt;[^&gt;]+&gt;/g, ""), d = d.replace(/&amp;nbsp;/ig, " "), d = d.replace(/\n\s*\n/g, "\n"), d = d.replace(/ {2}/g, " &amp;nbsp;"), b.newlineTag == "p" ? /\n/.test(d) &amp;&amp; (d = d.replace(/^/, "&lt;p&gt;").replace(/$/, "&lt;/p&gt;").replace(/\n/g, "&lt;/p&gt;&lt;p&gt;")) : d = d.replace(/\n/g, "&lt;br /&gt;$&amp;")), b.insertHtml(d, !0), b.html(b.text()))</pre><p><span style="color: #555555; font-family: '楷体 Std R'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 42px; orphans: auto; text-align: start; text-indent: 28px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">不难看出只是在最后的地方追加了</span></p>
<p><span style="color: #000000; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">b.html(b.text())</span></p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=1098</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>kindeditor编辑器高级篇：如何做到一键清除HTML格式的同时去掉kindeditor编辑器内全部超链接(a)</title>
		<link>https://www.softwareace.cn/?p=1095</link>
		<comments>https://www.softwareace.cn/?p=1095#comments</comments>
		<pubDate>Wed, 07 Jan 2015 09:51:02 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[chrome]]></category>
		<category><![CDATA[kindeditor]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=1095</guid>
		<description><![CDATA[在使用kindeditor编辑器的时候，大多数可能都是从某些网页直接粘贴内容复制到kindeditor编辑器内 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">在使用kindeditor编辑器的时候，大多数可能都是从某些网页直接粘贴内容复制到kindeditor编辑器内，这样可能内容就包含很多HTML标签和超链接。为了最快地进行内容编辑往往都使用kindeditor的“一键清除HTML”的功能，但是这个功能默认情况下是不会清除超链接的标签的。这一点往往令很多做编辑的人很是头疼，最后这个光荣的任务就落到了我们程序员的身上。</span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">为了解决在清除HTML标签的同时也清除掉超链接，不得不研究了一番kindeditor的源码。最后将其问题的解决方案归咎到了一键清除HTML的对应</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">plugins/clearhtml/</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">clearHTML.js文件内。通过深入分析得出了这样两个解决方案：</span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;"><strong style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;">1、修改formatHtml格式化方法</strong></span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">见</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">plugins/clearhtml/</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">clearHTML.js的formatHtml格式化方法如下所示：</span></p>
<p></p><pre class="crayon-plain-tag">html = K.formatHtml(html, {
			a : ['href', 'target'],
			embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
			img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height'],
			table : ['border'],
			'td,th' : ['rowspan', 'colspan'],
			'div,hr,br,tbody,tr,p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : []
});</pre><p>&nbsp;</p>
<div id="highlighter_372143" class="syntaxhighlighter " style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 1em 0px; padding: 1px; text-align: left; float: none; position: relative; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 950px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; color: #555555; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #e7e5dc;">
<div class="bar" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none;">
<div class="toolbar" style="border: 1px solid #e7e5dc; outline: 0px; font-size: 1px; vertical-align: baseline; margin: 0px; padding: 8px 8px 8px 0px; text-align: left; float: none; position: absolute; left: auto; top: 0px; right: 0px; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none #f8f8f8;"><a class="item viewSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/page_white_code.png') no-repeat;" title="view source" href="http://www.stepday.com/topic/?688#viewSource">view source</a><a class="item printSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/printer.png') no-repeat;" title="print" href="http://www.stepday.com/topic/?688#printSource">print</a><a class="item about" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/help.png') no-repeat;" title="?" href="http://www.stepday.com/topic/?688#about">?</a></div>
</div>
</div>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">从格式化方法不难看出它始终保持了a标签的href和target两个属性，所以问题的根本就在这里了的，解决方案就是去掉a标签的一切，修改后的代码如下所示：</span></p>
<p></p><pre class="crayon-plain-tag">html = K.formatHtml(html, {
			embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
			img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height'],
			table : ['border'],
			'td,th' : ['rowspan', 'colspan'],
			'div,hr,br,tbody,tr,p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : []
});</pre><p>&nbsp;</p>
<div id="highlighter_41853" class="syntaxhighlighter " style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 1em 0px; padding: 1px; text-align: left; float: none; position: relative; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 950px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; color: #555555; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #e7e5dc;">
<div class="bar" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none;">
<div class="toolbar" style="border: 1px solid #e7e5dc; outline: 0px; font-size: 1px; vertical-align: baseline; margin: 0px; padding: 8px 8px 8px 0px; text-align: left; float: none; position: absolute; left: auto; top: 0px; right: 0px; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none #f8f8f8;"><a class="item viewSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/page_white_code.png') no-repeat;" title="view source" href="http://www.stepday.com/topic/?688#viewSource">view source</a><a class="item printSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/printer.png') no-repeat;" title="print" href="http://www.stepday.com/topic/?688#printSource">print</a><a class="item about" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/help.png') no-repeat;" title="?" href="http://www.stepday.com/topic/?688#about">?</a></div>
</div>
<div class="lines" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;"></div>
</div>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;"><strong style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;">2、直接调用取消超链接的方法</strong></span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">通过查找源码内的方法，可以直接调用去掉超链接的方法，同样修改</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">plugins/clearhtml/</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">clearHTML.js文件内，在</span></span></p>
<div id="highlighter_587187" class="syntaxhighlighter " style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 1em 0px; padding: 1px; text-align: left; float: none; position: relative; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 950px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; color: #555555; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #e7e5dc;">
<div class="bar" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none;">
<div class="toolbar" style="border: 1px solid #e7e5dc; outline: 0px; font-size: 1px; vertical-align: baseline; margin: 0px; padding: 8px 8px 8px 0px; text-align: left; float: none; position: absolute; left: auto; top: 0px; right: 0px; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none #f8f8f8;"><a class="item viewSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/page_white_code.png') no-repeat;" title="view source" href="http://www.stepday.com/topic/?688#viewSource">view source</a><a class="item printSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/printer.png') no-repeat;" title="print" href="http://www.stepday.com/topic/?688#printSource">print</a><a class="item about" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/help.png') no-repeat;" title="?" href="http://www.stepday.com/topic/?688#about">?</a></div>
</div>
<div class="lines" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;">
<div class="line alt1" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;"><code class="number" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px 0.3em 0px 0px; text-align: right; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 3em; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; color: #5c5c5c; background: none;">1.</code><span class="content" style="border-width: 0px 0px 0px 3px; border-left-style: solid; border-left-color: #6ce26c; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px 0px 0px 3.3em; padding: 0px 0px 0px 0.5em; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; color: #000000; background: none #ffffff;"><span class="block" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px 0px 0px 1.5em; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; text-indent: -1.5em; background: url('http://www.stepday.com/images/wrapping.png') 0px 1.1em no-repeat;"><code class="plain" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #000000; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none;">self.addBookmark();</code></span></span></div>
</div>
</div>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">后面追加一句语句：</span></p>
<div id="highlighter_432333" class="syntaxhighlighter " style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 1em 0px; padding: 1px; text-align: left; float: none; position: relative; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 950px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; color: #555555; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #e7e5dc;">
<div class="bar" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none;">
<div class="toolbar" style="border: 1px solid #e7e5dc; outline: 0px; font-size: 1px; vertical-align: baseline; margin: 0px; padding: 8px 8px 8px 0px; text-align: left; float: none; position: absolute; left: auto; top: 0px; right: 0px; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none #f8f8f8;"><a class="item viewSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/page_white_code.png') no-repeat;" title="view source" href="http://www.stepday.com/topic/?688#viewSource">view source</a><a class="item printSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/printer.png') no-repeat;" title="print" href="http://www.stepday.com/topic/?688#printSource">print</a><a class="item about" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/help.png') no-repeat;" title="?" href="http://www.stepday.com/topic/?688#about">?</a></div>
</div>
<div class="lines" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;">
<div class="line alt1" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;"><code class="number" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px 0.3em 0px 0px; text-align: right; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 3em; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; color: #5c5c5c; background: none;">1.</code><span class="content" style="border-width: 0px 0px 0px 3px; border-left-style: solid; border-left-color: #6ce26c; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px 0px 0px 3.3em; padding: 0px 0px 0px 0.5em; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; color: #000000; background: none #ffffff;"><span class="block" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px 0px 0px 1.5em; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; text-indent: -1.5em; background: url('http://www.stepday.com/images/wrapping.png') 0px 1.1em no-repeat;"><code class="keyword" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #006699; font-weight: normal; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-style: normal; background: none;"><code class="plain" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #000000; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">self.exec(</code><code class="string" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: blue; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">'unlink'</code><code class="plain" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #000000; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">,<span class="Apple-converted-space"> </span></code><code class="keyword" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #006699; font-weight: normal; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">null</code><code class="plain" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #000000; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">);<span class="Apple-converted-space"> </span></code><code class="comments" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #008200; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">//去掉编辑器内所有的超链接</code></code></span></span></div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=1095</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>chrome 扩展 插件</title>
		<link>https://www.softwareace.cn/?p=47</link>
		<comments>https://www.softwareace.cn/?p=47#comments</comments>
		<pubDate>Wed, 16 Jan 2013 07:37:42 +0000</pubDate>
		<dc:creator><![CDATA[littlesu]]></dc:creator>
				<category><![CDATA[chrome]]></category>

		<guid isPermaLink="false">http://192.168.0.106/?p=47</guid>
		<description><![CDATA[&#160;chrome 有2种扩展 1.Browser Action；2.page actions &#038;nbs [&#8230;]]]></description>
				<content:encoded><![CDATA[<div>
	&nbsp;chrome 有2种扩展 1.Browser Action；2.page actions</p>
<p>
		&nbsp;</p>
<div>
		Chrome扩展就是几个网页，那么代码当然就是网页的JavaScript&nbsp;</div>
<div>
		有帮助的网页：<a href="http://blog.neverbest.com/?p=276">http://blog.neverbest.com/?p=276</a></div>
<div>
		google chrome api:&nbsp;<a href="http://developer.chrome.com/extensions/api_index.html">http://developer.chrome.com/extensions/api_index.html</a></div>
<div>
		chrome.browserAction&nbsp;<a href="http://developer.chrome.com/extensions/browserAction.html">http://developer.chrome.com/extensions/browserAction.html</a></div>
<div>
		{If you want to create an icon that isn&#39;t always visible, use a&nbsp;<a href="http://developer.chrome.com/extensions/pageAction.html">page action</a>&nbsp;instead of a browser action.&nbsp;}</div>
<div>
		chrome npapi:&nbsp;<a href="http://developer.chrome.com/extensions/npapi.html">http://developer.chrome.com/extensions/npapi.html</a></div>
<div>
		stackoverflow:&nbsp;<a href="http://stackoverflow.com/questions/2652094/start-an-external-application-from-a-google-chrome-extension">http://stackoverflow.com/questions/2652094/start-an-external-application-from-a-google-chrome-extension</a></div>
<div>
		chrome 应用：&nbsp;<a href="https://chrome.google.com/webstore/category/extensions?hl=zh-CN">https://chrome.google.com/webstore/category/extensions?hl=zh-CN</a></div>
<div>
		simple-get:&nbsp;<a href="http://www.chromeextensions.org/other/simple-get/">http://www.chromeextensions.org/other/simple-get/</a></div>
<div>
		simple-get&nbsp;git:&nbsp;<a href="https://github.com/repinel/SimpleGet">https://github.com/repinel/SimpleGet</a></div>
<div>
		extensions/samples:&nbsp;<a href="http://developer.chrome.com/extensions/samples.html">http://developer.chrome.com/extensions/samples.html</a></div>
<div>
		Browser Plugins vs Extensions &ndash; the difference &nbsp;<a href="http://colonelpanic.net/2010/08/browser-plugins-vs-extensions-the-difference/">http://colonelpanic.net/2010/08/browser-plugins-vs-extensions-the-difference/</a></div>
<div>
		An extension could contain a plugin, but a plugin can&rsquo;t contain an extension</div>
<div>
		&nbsp;</div>
<div>
		半路出现个这个</div>
<div>
		<a href="http://crossrider.com/signup">http://crossrider.com</a></div>
<div>
		<a href="http://kangoextensions.com/">http://kangoextensions.com/</a></div>
<div>
		<a href="http://www.chromeextensions.org/other/simple-get/">http://www.chromeextensions.org/other/simple-get/</a></div>
<div>
		<a href="http://stackoverflow.com/questions/4913123/cross-browser-extensions-api">http://stackoverflow.com/questions/4913123/cross-browser-extensions-api</a></div>
<div>
		&nbsp;</div>
<div>
		google&nbsp;Browser extension framework</div>
<div>
		&nbsp;</div>
<div>
		一个Chrme扩展是由HTML、CSS、JavaScript、图片等文件压缩而成。扩展实际上就是一个web页面，可以用任何浏览器提供给web页面的接口，从XMLHttpRequest 到JSON ，再到HTML本地缓存都可以使用。<br />
		Chrome扩展能做什么呢？我们会发现有些扩展在Chrome地址栏右侧区域增加一个图标。还有些扩展能够和浏览器的一些元素(如书签、tab导航标签)交互。扩展还可以和web页面交互，甚至是从web服务器获取数据。<br />
		每个扩展是 一个.crx文件（类似zip的 压缩文件），由下列文件组成<br />
		一个manifest文件(主文件,json格式)<br />
		至少一个HTML文件(主题可以没有HTML文件)<br />
		JavaScript文件 (可选，非必须)<br />
		任何其他你需要的文件(比如图片)</div>
<div>
		&nbsp;</div>
<div style="font-size: 21px">
		<b>工作原理</b></div>
<div>
		&nbsp;</div>
<div>
		<img src="/Users/littlesu/AppData/Local/Temp/enhtmlclip/%E5%9B%BE%E7%89%871.png" style="cursor: default" /></div>
<div>
		&nbsp;</div>
<div>
		&nbsp;</div>
<div>
<div>
<div>
				&nbsp;</div>
<div>
				读取用户计算机数据（<a href="http://developer.chrome.com/extensions/npapi.html">NPAPI Plugins</a>）</div>
<p>
				这个功能要用到dll（动态链接库）知识，可以启动用户电脑的程序，删除用户文件等功能。。相当于一个小Windows程序。利用Chrome提供的方法可以让扩展的后台页面与你的dll通信。</p>
<p>
				这些就API文档里的Implementation部分</p>
<div>
				<a href="http://blog.neverbest.com/wp-content/uploads/2010/05/20100511_230436.png"><img alt="2010-05-11_230436" border="0" height="194" src="/Users/littlesu/AppData/Local/Temp/enhtmlclip/Image.png" style="cursor: default" width="397" /></a></div>
<p>
				&nbsp;</p>
</p></div>
<div>
			&nbsp;</div>
<div>
			&nbsp;</div>
<div>
			<b style="font-size: 16px">Background page 和 PopUp&nbsp; page</b></div>
<div>
			<br />
			popup.html中定义的Javascript变量会在popup.html页面关闭时被释放，<br />
			background.html可以保存一些一直需要使用的变量的作用，这里定义的javascript变量会在Chrome浏览器生命期中一直存在，可以把要一直存在的数据保存在这里。<br />
			&nbsp;</div>
<div>
			先在background.html中定义好变量，</div>
<div>
			&nbsp;var&nbsp;global_email =&nbsp;&quot;&quot;;</div>
<div>
			然后在popup.html中用以下方式来引用这些变量</div>
<div>
			&nbsp;var&nbsp;bgpg = chrome.extension.getBackgroundPage();</div>
<div>
			bgpg.global_email =&nbsp;&quot;somebody@domain.com&quot;;</div>
<p>
			&nbsp;</p>
</p></div>
<div>
		&nbsp;</div>
<div style="font-size: 16px">
		<b>分析&nbsp;插件</b></div>
<div style="font-size: 16px">
		&nbsp;</div>
<div>
		manifest.json 主文件&nbsp;<a href="http://developer.chrome.com/extensions/manifest.html" style="font-size: 12px">Formats: Manifest Files</a><span style="font-size: 12px">&nbsp;</span></div>
<div>
		&nbsp;</div>
<div>
<h1 style="font-size: 29px">
			<font size="3" style="font-size: 16px">NPAPI Plugins</font></h1>
<p>
			&nbsp;</p>
</p></div>
<div>
		<span>JavaScript中调用本机二进制代码</span></div>
<div>
		&nbsp;How to develop an NPAPI plugin is outside the scope of this document. See&nbsp;<a href="https://developer.mozilla.org/en/Plugins">Mozilla&#39;s NPAPI plugin reference</a>&nbsp;for information on how to do that.</div>
<div>
		&nbsp;</div>
<div>
		<span>&ldquo;公共&rdquo;属性指定你的插件是否可以访问一般的网页，默认值为false，这意味着您的分机可以加载插件。</span></div>
<div>
		&nbsp;</div>
<div>
		&nbsp;</div>
<ol>
<li>
			Add a section to your extension&#39;s&nbsp;<code>manifest.json</code>&nbsp;that describes where to find the plugin, along with other properties about it:</p>
<p>
				&nbsp;</p>
<p>			</p><pre class="crayon-plain-tag">{
  &amp;quot;name&amp;quot;: &amp;quot;My extension&amp;quot;,
  ...
  &lt;b&gt;&amp;quot;plugins&amp;quot;: [
    { &amp;quot;path&amp;quot;: &amp;quot;content_plugin.dll&amp;quot;, &amp;quot;public&amp;quot;: true },
    { &amp;quot;path&amp;quot;: &amp;quot;extension_plugin.dll&amp;quot; }
  ]&lt;/b&gt;,
  ...}</pre><p></p>
<p>
				The &quot;path&quot; property specifies the path to your plugin, relative to the manifest file. The &quot;public&quot; property specifies whether your plugin can be accessed by regular web pages; the default is false, meaning only your extension can load the plugin.</p>
</li>
<li>
			<span style="font-family: Tahoma;text-align: -webkit-auto">Create an HTML file that loads your plugin by mime-type. Assuming your mime-type is &quot;application/x-my-extension&quot;:</span></p>
<p>
				&nbsp;</p>
<p>			</p><pre class="crayon-plain-tag">&amp;lt;embed type=&amp;quot;application/x-my-extension&amp;quot; id=&amp;quot;pluginId&amp;quot;&amp;gt;&amp;lt;script&amp;gt;
  var plugin = document.getElementById(&amp;quot;pluginId&amp;quot;);
  var result = plugin.myPluginMethod();  // call a method in your plugin
  console.log(&amp;quot;my plugin returned: &amp;quot; + result);&amp;lt;/script&amp;gt;</pre><p></p>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				This can be inside a background page or any other HTML page used by your extension. If your plugin is &quot;public&quot;, you can even use a content script to programmatically insert your plugin into a web page.</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="http://doc.qt.digia.com/solutions/4/qtbrowserplugin/developingplugins.html">http://doc.qt.digia.com/solutions/4/qtbrowserplugin/developingplugins.html</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				获取当前的页面的链接</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				google&nbsp;<a href="http://forums.macrumors.com/showthread.php?t=979578">http://forums.macrumors.com/showthread.php?t=979578</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="http://stackoverflow.com/questions/410411/get-current-page-url-from-a-firefox-sidebar-extension">http://stackoverflow.com/questions/410411/get-current-page-url-from-a-firefox-sidebar-extension</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="http://stackoverflow.com/questions/11493995/display-current-url-in-a-chrome-extension">http://stackoverflow.com/questions/11493995/display-current-url-in-a-chrome-extension</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				下一步封装库 fun(currentUrl);</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="http://www.lomox.hk/bbs-dz/forum.php?mod=viewthread&amp;tid=36">http://www.lomox.hk/bbs-dz/forum.php?mod=viewthread&amp;tid=36</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="/Users/littlesu/AppData/Local/Temp/enhtmlclip/NPAPI.rar"><img src="/Users/littlesu/AppData/Local/Temp/enhtmlclip/EN011b9301.png" /></a><a href="/Users/littlesu/AppData/Local/Temp/enhtmlclip/kango-framework-latest.zip"><img src="/Users/littlesu/AppData/Local/Temp/enhtmlclip/EN011b9310.png" /></a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				顺便看到个这个&nbsp;<a href="http://blog.csdn.net/ilvu999/article/details/8059572">LomoX常见问题</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				qt plugin&nbsp;</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;<a href="http://qt.gitorious.org/qt-solutions">http://qt.gitorious.org/qt-solutions</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="http://qt.gitorious.org/qt-solutions/qt-solutions/trees/master">http://qt.gitorious.org/qt-solutions/qt-solutions/trees/master</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="/Users/littlesu/AppData/Local/Temp/enhtmlclip/qt-solution.zip"><img src="/Users/littlesu/AppData/Local/Temp/enhtmlclip/EN011b9320.png" /></a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="http://www.chromeextensions.org/music-videos-photos/youtube-downloader/">http://www.chromeextensions.org/music-videos-photos/youtube-downloader/</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;</div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="http://blog.csdn.net/echoisland/article/details/7039012">http://blog.csdn.net/echoisland/article/details/7039012</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="http://mozilla.com.cn/post/21666/">http://mozilla.com.cn/post/21666/</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				<a href="http://open.chrome.360.cn/extension_dev/npapi.html">http://open.chrome.360.cn/extension_dev/npapi.html</a></div>
<div style="font-family: Tahoma;text-align: -webkit-auto">
				&nbsp;</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=47</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
