Fade In JavaScript/HTML Code

Status
Not open for further replies.

drexxo

Solid State Member
Messages
6
Location
United States
In this thread I will share me and my friend "Smithsonian" aka Terrance's code. We made it for one of our old free-domain beta code testing webs domains. It's just a sub-domain, but it is rather useful for testing codes like such. Here you are.
It basically just sets a message box, and fades it in on the load of the page. We used it for a newsclass and newsitem.

Enjoy!


This is the JavaScript Part to it.
This is setting the opacity, the timer for the duration of fade, and what the final opacity will be.
Code:
<script type="text/javascript"> 
		var opacity_val = 0;
		var opacity_timer;
		function page_load_fade() {
			document.getElementById('box').style.opacity = opacity_val;
			opacity_timer = setTimeout("increase_page_opacity()", 100);
		}
		function increase_page_opacity() {
			opacity_val = opacity_val + 0.1;
			if (opacity_val < 0.8) {
				document.getElementById('box').style.opacity = opacity_val;
				opacity_timer = setTimeout("increase_page_opacity()", 100);
			}
		}
	</script>
This is the HTML part of it
Here is the content of the fade in box. I sized everything that contains a message to a 5, so it should be easy for you Script Kiddies to copy/paste and just edit out what you need to.
Code:
<bgcolor="black"> 
<body onload="page_load_fade()"> 
<bgcolor="black"> 
	<h1 class="title" style="text-align: center; color: CCCCFF">[size="5"]Title Of Newsitem here[/size]</h1> 
	<div id="box" class="box" style="background-color: gray; text-align: center"> 
		<h2 class="no_opacity">[size="4"]Heading Goes Here[/title]</h2> 
		<i></i> 
 
	<div class="newsitem"> 
			<div class="message">[size="5"]MESSAGE TITLE HERE![/size]<br /> 
<br /> 
[SIZE="5"]MESSAGE/CONTENT GOES HERE!!!![/SIZE]<br /> 
 
<br /> </div> 
</div> <br /> 
			<div class="news_info">[size="5"]THIS WILL BE THE "who posted" information!!!</div> 
					</div> 
 
</text align> 
</div>
 
The JS is great. However, it would only ever be useful to learn from it. With APIs like jQuery and Spry already having very easy to use fade effects among many others, there wouldn't be much use of this in a production application. Thanks for sharing nonetheless.
 
Status
Not open for further replies.
Back
Top Bottom