It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Super noob question

Super noob question

Postby Naz on Wed Jul 23, 2008 2:07 pm

Hi,
I'm trying to build a website for my church...a very modest website as I'm a total noob. I'm using Dreamweaver 8 and here is what I'm trying to accomplish.

I want the text Welcome Home to fade into one of my tables about 1 second after the page loads.

I'm handling the HTML ok but I'm clueless on JS.

Thanks
Naz
Naz
 
Posts: 2
Joined: Wed Jul 23, 2008 1:57 pm

Postby rangana on Thu Jul 24, 2008 12:10 am

See if this basic example helps:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
#box {
    width:300px;
    padding:10px;
    border:3px double #999;
    font-family:verdana,arial,helvetica,sans-serif;
    font-size:24px;
    text-align:center;
    margin:30px auto;
}
#text {
    height:100%;
    color:#000;
    filter:alpha(opacity=0);
    opacity:0;
}
</style>

<script type="text/javascript">
  var c=0;
  var d=0;
  var seconds=3; /* this will give 3 seconds delay before text disappears */
  var k=0;
  var speed=100;
  var delay=100+(1000/speed)*seconds;
  var obj;

window.onload=function() {
   obj=document.getElementById('text');
   fadeIn();
}
function fadeIn() {
   c++;
   d++;
if(obj.filters) obj.style.filter='alpha(opacity='+c+')';
else obj.style.opacity=c/100;
obj.firstChild.nodeValue=obj.firstChild.nodeValue;
if(d==delay){k++;c=0;d=0;}
setTimeout('fadeIn()',speed);
}
</script>

</head>
<body>
<div id="box">
<div id="text">Welcome Home</div>
</div>
</body>
</html>
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby Naz on Thu Jul 24, 2008 4:53 am

Hi rangana,
Thank you very much for answering my question. I plugged your code into my page and it worked. The only problem I have is it changed a lot of the formatting for everything else such as font, color, and size on text on the rest of the page. Is there anyway I can send you the orginal HTML I wrote and the new with your JS and you could show me where I went wrong? I would truly appreciate it. And thanks again for the script it went a long way in showing me how my page reacts to the script, I learned a lot from it.

Naz
Naz
 
Posts: 2
Joined: Wed Jul 23, 2008 1:57 pm

Postby rangana on Thu Jul 24, 2008 4:59 am

Oh, my apologies. Please do so.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 4 guests