<?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; tinyMCE</title>
	<atom:link href="http://bluehua.org/tag/tinymce/feed" rel="self" type="application/rss+xml" />
	<link>http://bluehua.org</link>
	<description>分享所学,backup一切~</description>
	<lastBuildDate>Wed, 23 Nov 2011 08:43:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>tinyMCE:ie下无法自动转换粘贴文本中的相对路径</title>
		<link>http://bluehua.org/2009/04/27/265.html</link>
		<comments>http://bluehua.org/2009/04/27/265.html#comments</comments>
		<pubDate>Mon, 27 Apr 2009 07:09:01 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[web dev]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tinyMCE]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=265</guid>
		<description><![CDATA[一般来说如果我从http://abc.com/about.html把下面一段带有相对路径的文字粘贴到一个富文本编辑器 xx&#60;a href=&#34;help.html&#34;&#62;help&#60;/a&#62; 应当自动转换为如下形式 xx&#60;a href=&#34;http://abc.com/help.html&#34;&#62;help&#60;/a&#62; 这样里面的相对路径链接才不会失效，但是发现tinyMCE在ie下面却不会自动转换。以为其他网站也会这样，但是试了一下sina博客的编辑器却没有这个问题，看来应该是tinyMCE本身的问题。 查了许久，发现tinyMCE即使不传document_base_url这个参数也会自作聪明的加一个&#60;base /&#62;标签,而href的值就是当前路径。从而导致ie不再自动转换粘贴内容里的相对路径，所以只要删除这个元素便可解决问题，hack如下： &#40;function&#40;&#41; &#123; tinymce.create&#40;'tinymce.plugins.bluePatch', &#123; &#160; init : function&#40; ed, url &#41; &#123; ed.onInit.add&#40; function&#40; ed, cm&#41; &#123; var b = ed.getDoc&#40;&#41;.getElementsByTagName&#40; 'base' &#41;&#91; 0 &#93;; //发现直接删除会出问题，所以删除href就够了 b.removeAttribute&#40; 'href' &#41;; &#125;&#41;; &#125; &#125;&#41;; &#160; tinymce.PluginManager.add&#40; 'bluePatch', tinymce.plugins.bluePatch &#41;; &#125;&#41;&#40;&#41;;]]></description>
			<content:encoded><![CDATA[<p>一般来说如果我从http://abc.com/about.html把下面一段带有相对路径的文字粘贴到一个富文本编辑器</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;">xx&lt;a href=&quot;help.html&quot;&gt;help&lt;/a&gt;</pre></div></div>

<p>应当自动转换为如下形式</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;">xx&lt;a href=&quot;http://abc.com/help.html&quot;&gt;help&lt;/a&gt;</pre></div></div>

<p>这样里面的相对路径链接才不会失效，但是发现tinyMCE在ie下面却不会自动转换。以为其他网站也会这样，但是试了一下sina博客的编辑器却没有这个问题，看来应该是tinyMCE本身的问题。</p>
<p>查了许久，发现tinyMCE即使不传<a href="http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/document_base_url">document_base_url</a>这个参数也会自作聪明的加一个&lt;base /&gt;标签,而href的值就是当前路径。从而导致ie不再自动转换粘贴内容里的相对路径，所以只要删除这个元素便可解决问题，hack如下：</p>

<div class="wp_syntax"><div class="code overflow"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    tinymce.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tinymce.plugins.bluePatch'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        init <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> ed<span style="color: #339933;">,</span> url <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            ed.<span style="color: #660066;">onInit</span>.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> ed<span style="color: #339933;">,</span> cm<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> ed.<span style="color: #660066;">getDoc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'base'</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: #339933;">;</span>
                <span style="color: #006600; font-style: italic;">//发现直接删除会出问题，所以删除href就够了</span>
                b.<span style="color: #660066;">removeAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'href'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    tinymce.<span style="color: #660066;">PluginManager</span>.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'bluePatch'</span><span style="color: #339933;">,</span> tinymce.<span style="color: #660066;">plugins</span>.<span style="color: #660066;">bluePatch</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2009/04/27/265.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.355 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-05 03:30:39 -->

