<?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>Leeiio Chaos Made. &#187; CSS nake day</title>
	<atom:link href="http://leeiio.me/tag/css-nake-day/feed/" rel="self" type="application/rss+xml" />
	<link>http://leeiio.me</link>
	<description>The world is golden.</description>
	<lastBuildDate>Thu, 26 Apr 2012 03:54:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>拥抱 CSS 裸奔节，用 JavaScript 强制脱衣</title>
		<link>http://leeiio.me/force-remove-css-in-css-nake-day/</link>
		<comments>http://leeiio.me/force-remove-css-in-css-nake-day/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 02:37:59 +0000</pubDate>
		<dc:creator>Leeiio</dc:creator>
				<category><![CDATA[Skill | 技术]]></category>
		<category><![CDATA[CSS 裸奔节]]></category>
		<category><![CDATA[CSS nake day]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[强制脱衣]]></category>
		<category><![CDATA[强制去除 CSS]]></category>

		<guid isPermaLink="false">http://leeiio.me/?p=1250</guid>
		<description><![CDATA[因为我的博客很多时候都是处在调试中的，并且很多插件诸如 Simple Tags 是直接在标签里给元素加上 CSS 的，所以如果想要“裸奔”光是去除 .css 文件是远远不够的，那么有没有一种强制的方法呢？我昨晚就在想这样一种方法。于是被我想到了。也就是本文介绍如何 “<strong>强制脱衣</strong>” ，也就是教你<strong>如何强制去除网站的 CSS</strong> ！

<strong>实现原理：</strong>众所周知，CSS 调用有三种方法，一种是 link 方式，一种是 &#60;style&#62;&#60;/style&#62; 包裹方式，最后一种就是直接且暴力的 style="" 方式，通过 Javascript 代码，强制禁用 type="text/css" 的 link 或者 让 link 链接 css 的 href="" 为空，且让 &#60;style&#62;&#60;/style&#62;
被清除或者禁用，且让 style="" 为空 或者去除。 <a href="http://leeiio.me/force-remove-css-in-css-nake-day/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://imgs.leeiio.me/blogimgs/2009/04/20090409_cssnake.jpg" alt="CSS 裸奔节" /><br />
很早就有人 Twitter 说今天是 CSS 裸奔节，于是&#8230;</p>
<h3>CSS Naked Day 的来历</h3>
<p><a title="CSS Naked Day的发起者页面" rel="nofollow" href="http://naked.dustindiaz.com/">CSS Naked Day</a>，也称 CSS 裸奔节或 CSS 裸奔日。</p>
<p>在裸奔节这天，参加裸奔节的Blog 将会去除页面上所有的 CSS 样式和广告裸奔整整一天,通过这个节日来重视 CSS 的重要性.当然你的网站如果是用 table 来布局的话这个节日对你来说并不是很合适.在2006年有将近800个国际知名网站参与这个节日.而今年CSS Naked Day将由之前的24小时改为48小时!<br />
<span id="more-1250"></span></p>
<h3>CSS Naked Day 的目的</h3>
<p>推动Web标准、提倡简洁为美、使用正确的 (x)html 语义标记、良好的层次结构。暂时把页面设计抛弃，直接展示&lt;body&gt;内容！</p>
<h3>历届CSS Naked Day的举办时间</h3>
<p>第一届 CSS 裸奔节：2006年4月5日</p>
<p>第二届 CSS 裸奔节：2007年4月5日</p>
<p>第三届 CSS 裸奔节：2008年4月9日</p>
<p>第四届 CSS 裸奔节：2009年4月9日</p>
<p>- <a href="http://blog.taoxian.info/2009-css-naked-day.html">Via</a></p>
<p>你可以前往<a href="http://naked.dustindiaz.com/" rel="nofollow">官方网站</a>查看更多的介绍以及了解如何加入这个活动。</p>
<p>然后，回到本文的重点。因为我的博客很多时候都是处在调试中的，并且很多插件诸如 Simple Tags 是直接在标签里给元素加上 CSS 的，所以如果想要“裸奔”光是去除 .css 文件是远远不够的，那么有没有一种强制的方法呢？我昨晚就在想这样一种方法。于是被我想到了。也就是本文介绍如何 “<strong>强制脱衣</strong>” ，也就是教你<strong>如何强制去除网站的 CSS</strong> ！</p>
<p><strong>实现原理：</strong>众所周知，CSS 调用有三种方法，一种是 link 方式，一种是 &lt;style&gt;&lt;/style&gt; 包裹方式，最后一种就是直接且暴力的 style=&#8221;" 方式，通过 Javascript 代码，强制禁用 type=&#8221;text/css&#8221; 的 link 或者 让 link 链接 css 的 href=&#8221;" 为空，且让 &lt;style&gt;&lt;/style&gt;<br />
被清除或者禁用，且让 style=&#8221;" 为空 或者去除。</p>
<p>这里提供两种方法，一种是最普通的 Javascript 来实现，另外一种是通过目前的最流行的 Javascript 库 jQuery 来实现。</p>
<p><strong>第一种（普通版）：</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/JavaScript&quot;</span><span style="color: #339933;">&gt;</span>	
<span style="color: #006600; font-style: italic;">// 用style方式引用的css</span>
<span style="color: #003366; font-weight: bold;">var</span> style<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> s<span style="color: #339933;">=</span><span style="color: #3366CC;">'Style:'</span> <span style="color: #339933;">+</span> style.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>style.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #009966; font-style: italic;">/*s += style.item(i) + '|';*/</span>
    style.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">disabled</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// 用link方式引用的css</span>
<span style="color: #003366; font-weight: bold;">var</span> link <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'link'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
s <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'Link:'</span> <span style="color: #339933;">+</span> link.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>link.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'text/css'</span> <span style="color: #339933;">==</span> link.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">type</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #009966; font-style: italic;">/*s += link.item(i).href + &quot;|\\n&quot;;*/</span>
            link.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">disabled</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// 任意对象的style=&quot;&quot;</span>
<span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">childNodes</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'*'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
s <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'Obj:'</span> <span style="color: #339933;">+</span> obj.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>obj.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>   
    obj1 <span style="color: #339933;">=</span> obj.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>obj1.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        s <span style="color: #339933;">+=</span> obj1.<span style="color: #660066;">nodeName</span> <span style="color: #339933;">+</span> obj1.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>n&quot;</span><span style="color: #339933;">;</span>
        obj1.<span style="color: #660066;">attributes</span>.<span style="color: #660066;">getNamedItem</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>只需将以上这段 JS 代码插入你的网页中即可。</p>
<p><strong>接着是第二种（jQuery版）</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/JavaScript&quot;</span><span style="color: #339933;">&gt;</span>		
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><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>
	<span style="color: #006600; font-style: italic;">// 用link方式引用的css</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;link&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">,</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> 
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;text/css&quot;</span><span style="color: #009900;">&#41;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;href&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&quot;</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> 
&nbsp;
	<span style="color: #006600; font-style: italic;">// 任意对象的style=&quot;&quot;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;*&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeAttr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;style&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// 用style方式引用的css</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;style&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</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: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>如果你的网站启用了 jQuery 库的话，那么毫不犹豫地用第二种吧，你看代码是何其简洁啊！</p>
<p><strong>最后祝大家裸奔愉快！</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://leeiio.me/force-remove-css-in-css-nake-day/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>

