473,467 Members | 1,604 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Want to print string of text with effect, can u help? :)

I am looking for a javascript function ( don't know what they call ths
) which will print a line of text, one letter at a time at a certain
speed until the full string is printed. Can this be done simply, and
is there a easy way to accomplish this? Sincerely, Jean

Dec 13 '06 #1
3 1594
ap**********@gmail.com wrote:
I am looking for a javascript function ( don't know what they call ths
) which will print a line of text, one letter at a time at a certain
speed until the full string is printed. Can this be done simply, and
is there a easy way to accomplish this? Sincerely, Jean
http://www.htmlcodetutorial.com/_MARQUEE.html

Surprisingly both IE and Firefox support MARQUEE though it's rarely used
if you hit a roadblock with javascript you might find the tag useful.

<HTML>
<HEAD>
</HEAD>
<BODY>

<marquee width=200 behavior=scroll direction=right LOOP=1>To marquee or
not to marquee, that is the question.</marquee>

<div id='marqueeDiv'></div>

<script language='javascript' type='text/javascript'>
<!--
var announce='Insert your string here.';
var speed=1000; // 1000=1 second.
var marqueeLayer=document.getElementById('marqueeDiv') ;
var currPos = 0;

function doType() {
marqueeLayer.innerHTML += announce.substring(currPos,currPos+1);
currPos++;
if (currPos<announce.length) {
setTimeout('doType()',speed);
}
}

doType();
//-->
</script>

</body>
</html>--
http://www.hunlock.com -- Musings in Javascript, CSS.
$FA
Dec 13 '06 #2
ap**********@gmail.com wrote in news:1165975228.349093.63300
@l12g2000cwl.googlegroups.com:
I am looking for a javascript function ( don't know what they call ths
) which will print a line of text, one letter at a time at a certain
speed until the full string is printed. Can this be done simply, and
is there a easy way to accomplish this? Sincerely, Jean
<div id="myoutput"></div>

var txtStr = "The quick brown fox jumped over a lazy dog.";
speed = 1000; //one second
var i = 0;
function writeone() {
document.getElementById('myoutput').innerHTML +=
txtStr.charAt(i);

i++;
if (i != txtStr.length) {
junk = setTimeout(writeone,speed);
}
}

writeone(); //call it once, then it calls itself
Dec 13 '06 #3
pcx99 wrote:
ap**********@gmail.com wrote:
I am looking for a javascript function ( don't know what they call ths
) which will print a line of text, one letter at a time at a certain
speed until the full string is printed. Can this be done simply, and
is there a easy way to accomplish this? Sincerely, Jean
[snip example]

The example has all the ideas I would use. Below it is just changed a
little with a few suggestions that might help sometimes.

There is no need for the language attribute of the script tag. It is
deprecated.

<http://www.w3schools.com/tags/tag_script.asp>

The comment script hiding technique is not needed anymore. It was for
some browsers in 1995 or a similarly long time ago.

Use a doctype.

Use double quotes around attribute values for valid markup.
http://validator.w3.org/

In the following example the script in the head element could be in a
separate JavaScript file so that the browser can cache it.

The following uses the widely supported but non-standard innerHTML
property. This could be changed to standard compliant code.

The first argument to setTimeout can be a function or a string. I like
a function.

- Peter

---------------------------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Marquee</title>

<script type="text/javascript">
function announce(id, str, period) {
var el = document.getElementById(id);
var pos = 0;
function doType() {
el.innerHTML = str.substring(0, ++pos);
if (pos < str.length) {
setTimeout(doType, period);
}
}
doType();
}
</script>

</head>
<body>

<div id="marqueeDiv"></div>

<script type="text/javascript">
announce('marqueeDiv', 'Insert your string here.', 200);
</script>

</body>
</html>

Dec 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Geoff Cox | last post by:
Hello, I am trying to have 1. web pages in large font 2. web pages with smaller font for printing I am using <link rel="stylesheet" media="print" type="text/css"
12
by: Peter Lin | last post by:
Hey, I am just wondering if anyone has got any idea of setting up a new class so that you could just print like the old ways with the printer class, since I am writing a program that really...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
5
by: Ron | last post by:
I've got some C# code that sort of does what I want: Looking at the xml files in area: http://www.keepitsimplekid.com/xml I want to change Untitled Ad at the top of the xml to the name of the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.