printing the content on to web page after loading like a type writer
<html>
<head>
<title>TypeWriter Example</title>
<script>
var g_typeDelay = 200;//milli seconds
function typewriter( objID )
{
setTimeout("type('"+objID+"',0)", 1);
}
function type( objID, pos )
{
var txt = document.all[objID].childNodes(0).nodeValue;
document.all[objID].childNodes(1).innerHTML += txt.charAt(pos++);
if ( pos < txt.length-1 ) setTimeout("type('"+objID+"',"+pos+")", g_typeDelay);
}
</script>
</head>
<body onload="typewriter('txt1'); typewriter('txt2');">
<div id='txt1'><!-- First Example --><span></span></div>
<div id='txt2'><!-- Second Example --><span></span></div>
</body>
</html>
hi kinghtweb ,
thank you for your reply.i got the output.
can you just tell me where can i find the material regarding the functions used in your code or if you can,please share the required material with me.
if i want to add another functionality like
after printing one line. if i want to clear the line and print the second line what should i do?
Message was edited by:
santhosh_thadvai
Here they are....The language is called JavaScript and its not the same as Java (similar syntax but not OO). It runs only in browsers and is used to control web content after the page is served to the client.
JavaScript API reference
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/29f83a2c-48c5-49e2-9ae0-7371d2cda2ff.asp
CSS reference
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/css/reference/attributes.asp
DHTML reference
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp
If you're coding for the web then these references are invaluable.
Don't foget the other post too. Thank you.
Ok to clear the line create a function like this :-
function clearLine( id )
{
document.all[id].childNodes(1).innerHTML="";
}
If you want to print the second line at that point you can just call the functioin I placed on the "onload" part of body.....passing the correct ID.
If you want to do it all in a sequence after the page load then create a new function, say perhaps called "sequence" and put this in the "onload" instead of the other two functions. In this new function you can create a sequence of method calls......for example
function sequence()
{
setTimeout("type('txt1',0)", 1);
setTimeout("clearLine('txt1'); type('txt2',0);", 1000);
//.....etc
}
You need to read the JavaScript API its got lots of cool calls that you can make and the DHTML will help you change the HTML objects on the fly. Plus there are loads of simple examples on the sites I sent you.
Hope this helps..
> Here they are....The language is called JavaScript
> and its not the same as Java (similar syntax but not
> OO). It runs only in browsers and is used to control
> web content after the page is served to the client.
gotta pick you up there. javascript is indeed OO. not only that, it's nicely duck-typed, too. you can do all sorts of crazy things in javascript, like nail new methods to an object at runtime. it's not only limited to running in browsers, either. for instance, you can write plugins for dreamweaver et al in javascript
Sure, you'e got me there......I was trying to keep it simple. You're right indeed it is OO and far more flexible than Java (perhaps a little messy though), personally its my favourite language, its amazing what you can do in it..........we could even go into server side scripting, signed scripts, AJAX, Flash integration, SVG......etc....etc... but I think this poster has a steep enough learning curve as it is.
Plus JavaScripts OO is very loose in the sense you can do almost any crazy thing you can think of.....which is good in the right hand, also the fact it is untyped make it a very hard language for a beginer to understand and write good code in.Java helps the learning much more because of its stricter type and OO implementation.
Still no excuse for posting misleading info.