<?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>AEXT.NET MAGAZINE &#187; randomize</title>
	<atom:link href="http://aext.net/tag/randomize/feed/" rel="self" type="application/rss+xml" />
	<link>http://aext.net</link>
	<description>How to Create a Website</description>
	<lastBuildDate>Wed, 30 May 2012 05:03:57 +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>Relax with Javascript: Randomize Your CSS Style</title>
		<link>http://aext.net/2009/11/javascript-random-css-style/</link>
		<comments>http://aext.net/2009/11/javascript-random-css-style/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 23:50:14 +0000</pubDate>
		<dc:creator>Lief</dc:creator>
				<category><![CDATA[CSS & HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[CSS & XHTML]]></category>
		<category><![CDATA[randomize]]></category>

		<guid isPermaLink="false">http://aext.net/?p=1396</guid>
		<description><![CDATA[<p><a href="http://aext.net/theme/platinoom" title="Platinoom - Premium WordPress Themes"><img src="http://aext.net/wp-content/uploads/2011/04/platinoom_wordpress_theme.png" alt="ThemeKiss" /></a></p><p style="float: right;"><a href="http://api.tweetmeme.com/share?url=http://aext.net/2009/11/javascript-random-css-style/&service=su.pr&service_api=b57727e991c454bd2b2c62ff71462c79"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http://aext.net/2009/11/javascript-random-css-style/" height="61" width="51" /></a></p>This is just a small tip for fun. Sometime, we are bored with the only-one style in our website, but today, we will make some changes. We will create a javascript to randomize the CSS everytime we refresh the web page. For what? Just make our style always get new. <a href="http://aext.net/2009/11/javascript-random-css-style/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://aext.net/theme/platinoom" title="Platinoom - Premium WordPress Themes"><img src="http://aext.net/wp-content/uploads/2011/04/platinoom_wordpress_theme.png" alt="ThemeKiss" /></a></p><p style="float: right;"><a href="http://api.tweetmeme.com/share?url=http://aext.net/2009/11/javascript-random-css-style/&service=su.pr&service_api=b57727e991c454bd2b2c62ff71462c79"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http://aext.net/2009/11/javascript-random-css-style/" height="61" width="51" /></a></p><p>This is just a small tip for fun. Sometime, we are bored with the only-one style in our website, but today, we will make some changes. We will create a javascript to randomize the CSS every time we refresh the web page. For what? Just make our style always get new.</p>
<p><span id="more-1396"></span></p>
<p><strong>Try to refresh the demo page to see the effect.</strong></p>
<div class="demo-download">
<ul>
<li><a class="downloadit" href="http://www.box.net/shared/0z9058ij4l">Download</a></li>
<li><a class="demoit" href="http://aext.net/example/randomize-css-javascript/">Demo</a></li>
</ul>
</div>
<p>We will use javascript function Math.random() to generate a random number between 0 and number of elements of an array which is an arrangement of stylesheet items.</p>
<p>Create a new javascript file which contains this function:</p>
<pre class="javascript"><span style="color: #881350;">function</span> <span style="color: #003369;">rand</span>(){
Â Â Â Â <span style="color: #881350;">return</span> Math.<span style="color: #003369;">round</span>(Math.<span style="color: #003369;">random</span>()*(css.length-<span style="color: #0000ff;">1</span>));
}</pre>
<p>This gets us numbers from 0 to &lt; (css.length-1) (Because the elements start from 0) which is this array below:</p>
<pre class="javascript"><span style="color: #881350;">var</span> css = <span style="color: #881350;">new</span> <span style="color: #003369;">Array</span>(
Â Â Â Â <span style="color: #760f15;">'&lt;link rel="stylesheet" type="text/css" href="default.css"&gt;'</span>,
Â Â Â Â <span style="color: #760f15;">'&lt;link rel="stylesheet" type="text/css" href="style2.css"&gt;'</span>,
Â Â Â Â <span style="color: #760f15;">'&lt;link rel="stylesheet" type="text/css" href="style3.css"&gt;'</span>,
Â Â Â Â <span style="color: #760f15;">'&lt;link rel="stylesheet" type="text/css" href="style4.css"&gt;'</span>
);</pre>
<p>Then write it in HTML</p>
<pre class="javascript">rand = <span style="color: #003369;">rand</span>();

document.<span style="color: #003369;">write</span>(css[rand]);</pre>
<p>That&#8217;s it! Enjoy the random CSS by refresh your webpage. Your random effect will show clearly if you have many elements in array. The more elements, the less repeat.</p>
<div class="txtad-cont"></div>
]]></content:encoded>
			<wfw:commentRss>http://aext.net/2009/11/javascript-random-css-style/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

