<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Five 's Weblog &#187; setInterval</title>
	<atom:link href="http://powerdream5.wordpress.com/tag/setinterval/feed/" rel="self" type="application/rss+xml" />
	<link>http://powerdream5.wordpress.com</link>
	<description>It is not just another blog! 伍行天下！</description>
	<lastBuildDate>Wed, 28 Nov 2007 21:21:29 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='powerdream5.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/b83f3cb0955eab114902a009525db137?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Five 's Weblog &#187; setInterval</title>
		<link>http://powerdream5.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://powerdream5.wordpress.com/osd.xml" title="Five &#8217;s Weblog" />
		<item>
		<title>Two useful javascript methods!</title>
		<link>http://powerdream5.wordpress.com/2007/10/17/two-useful-javascript-methods/</link>
		<comments>http://powerdream5.wordpress.com/2007/10/17/two-useful-javascript-methods/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 01:53:38 +0000</pubDate>
		<dc:creator>powerdream5</dc:creator>
				<category><![CDATA[Five's thought]]></category>
		<category><![CDATA[createElement]]></category>
		<category><![CDATA[setInterval]]></category>

		<guid isPermaLink="false">http://powerdream5.wordpress.com/2007/10/17/two-useful-javascript-methods/</guid>
		<description><![CDATA[       Recently, I help one of my friends do some javasript stuff. I found two useful methods and want to share them with you.
       Firstly, please open this web link and see the effect of the example. Perhaps there are two highlight attracting you, the transparent background and the size of the frame changing dynamically. (If [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=powerdream5.wordpress.com&blog=1840509&post=59&subd=powerdream5&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://powerdream5.files.wordpress.com/2007/10/10_17_1_2007.jpg" title="10_17_1_2007.jpg"></a>       Recently, I help one of my friends do some javasript stuff. I found two useful methods and want to share them with you.</p>
<p>       Firstly, please <a target="_blank" href="http://chenyonghui.byethost13.com/powerdream5/javascript.html">open this web link </a>and see the effect of the example. Perhaps there are two highlight attracting you, the transparent background and the size of the frame changing dynamically. (If you think it does not interest you, I am sorry to waste your time). Now, I am going to explain how can I realize the two functions. It is pretty easy.</p>
<p><strong>Using the method setInterval()</strong><br />
The setInterval method calls a function at specified intervals. It has two required parameters. The first parameter is a pointer to a function, and the second parameter is the number of milliseconds. It is easy to create some animation effect by using this method, for example, moving some elements and changing the size of some elements. There is an example about changing the size of a &#8220;div&#8221;.</p>
<p><font color="#ff0000">//get the reference of the &#8221;div&#8221; of which you want to change the size</font><br />
var div = document.getElementById(&#8220;divId&#8221;);<br />
<font color="#ff0000">//set the initial width and height of the &#8220;div&#8221; to 0<br />
</font>div.style.width= 0 + &#8220;px&#8221;;<br />
div.style.height = 0 + &#8220;px&#8221;;<br />
var width = 0;<br />
var height = 0;<br />
<font color="#ff0000">//the changeSize() method will be called every 10 millionseconds</font><br />
var interval = setInterval(&#8220;changeSize()&#8221;,10);<br />
function changeSize(){<br />
        width += 10;<br />
        height + 10;</p>
<p>       div.style.width = width + &#8220;px&#8221;;<br />
       div.style.height = heigjt + &#8220;px&#8221;;<br />
       if(width &gt;= 500)<br />
      {<br />
            <font color="#ff0000"> //clearInterval() method will stop the call to the changeSize() method</font><br />
             clearInterval(interval);<br />
       }<br />
}</p>
<p><strong>Using the method createElement()</strong><br />
The createElement() method creates an element node. In the example you saw at the beginning of this article, I firstly created a &#8220;div&#8221; node, and setted the style of this node, then append it to the html body.</p>
<p>var tbody = document.getElementsByTagName(&#8220;body&#8221;)[0];<br />
<font color="#ff0000">//create a &#8220;div&#8221; node, you can also create &#8220;table&#8221;, &#8220;tr&#8221;,etc.</font><br />
var tnode = document.createElement(&#8220;div&#8221;);</p>
<p><font color="#ff0000">//set the style</font><br />
tnode.style.position = &#8220;absolute&#8221;;<br />
tnode.style.top = &#8220;0px&#8221;;<br />
tnode.style.left = &#8220;0px&#8221;;<br />
tnode.style.overflow = &#8220;hidden&#8221;;<br />
<font color="#ff0000">//set the id of the new &#8220;div&#8221;</font><br />
tnode.id = &#8220;darkScreenDiv&#8221;;</p>
<p><font color="#ff0000">//to make it transparent</font>  <br />
tnode.style.opacity = 0.7;<br />
tnode.style.MozOpacity = 0.7;<br />
tnode.style.filter = &#8220;alpha(opacity=&#8221;+70+&#8221;)&#8221;;<br />
<font color="#ff0000">//set the depth, to make sure it is over the other elements of this web page.</font><br />
<font color="#ff0000">//the biggerthe value is, the topper the element is</font><br />
tnode.style.zIndex = 100;</p>
<p><font color="#ff0000">//set the width and height of this &#8220;div&#8221; node</font><br />
tnode.style.width = document.documentElement.clientWidth + &#8220;px&#8221;;<br />
tnode.style.height = document.documentElement.clientHeight + &#8220;px&#8221;;<br />
tnode.style.display = &#8220;block&#8221;;</p>
<p><font color="#ff0000">//append it to the html body</font><br />
tbody.appendChild(tnode);</p>
<p align="center"><a href="http://powerdream5.files.wordpress.com/2007/10/10_17_1_2007.jpg" title="10_17_1_2007.jpg"></p>
<p style="text-align:center;"><img src="http://powerdream5.files.wordpress.com/2007/10/10_17_1_2007.jpg" alt="10_17_1_2007.jpg" /></p>
<p></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/powerdream5.wordpress.com/59/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/powerdream5.wordpress.com/59/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/powerdream5.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/powerdream5.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/powerdream5.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/powerdream5.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/powerdream5.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/powerdream5.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/powerdream5.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/powerdream5.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/powerdream5.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/powerdream5.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=powerdream5.wordpress.com&blog=1840509&post=59&subd=powerdream5&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://powerdream5.wordpress.com/2007/10/17/two-useful-javascript-methods/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a0819a06b6ff4afc4f3e0a1977e6a5a2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">powerdream5</media:title>
		</media:content>

		<media:content url="http://powerdream5.files.wordpress.com/2007/10/10_17_1_2007.jpg" medium="image">
			<media:title type="html">10_17_1_2007.jpg</media:title>
		</media:content>
	</item>
	</channel>
</rss>