473,666 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript Typewriter Ticker

Dan
Hi

Does anyone know of a good Javascript typewriter ticker that allows
you to insert HTML into the ticker. I have found lots but when HTML is
inserted, the ticker pauses at the point it reaches the HTML as well
as applying the formatting. I need one whose character timer ignores
characters in tags. I need to apply font color and weight styling to
different words.

Please see www.launchpr.co.uk for how the ticker currently looks in
Flash - it needs to be replaced with HTML/JavaScript which produces
the same effect.

Thanks in advance

Dan
Jul 23 '05 #1
3 6673
Dan wrote on 12 mrt 2005 in comp.lang.javas cript:
Does anyone know of a good Javascript typewriter ticker that allows
you to insert HTML into the ticker. I have found lots but when HTML is
inserted, the ticker pauses at the point it reaches the HTML as well
as applying the formatting. I need one whose character timer ignores
characters in tags. I need to apply font color and weight styling to
different words.


This is not that easy.

I suppose you want to innerHTML:

text = 'Hello <span style="color:re d;">world</span>!'

as:

H
He
Hel
Hell
Hello
Hello
Hello <span style="color:re d;">w</span>
Hello <span style="color:re d;">wo</span>
Hello <span style="color:re d;">wor</span>
Hello <span style="color:re d;">worl</span>
Hello <span style="color:re d;">world</span>
Hello <span style="color:re d;">world</span>!

If also other HTML is inserted,
you will need a parser the size of the jscript engine, I suppose.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2
Dan wrote:
Hi

Does anyone know of a good Javascript typewriter ticker that allows
you to insert HTML into the ticker. I have found lots but when HTML is inserted, the ticker pauses at the point it reaches the HTML as well
as applying the formatting. I need one whose character timer ignores
characters in tags. I need to apply font color and weight styling to
different words.

Please see www.launchpr.co.uk for how the ticker currently looks in
Flash - it needs to be replaced with HTML/JavaScript which produces
the same effect.

Thanks in advance

Dan


Better agenda:

#:=( DHTML ----------> Flash #:=)

It's easy to write this; the problem isn't passing the tags whole into
the 'stream' (easy to do with a RegExp or while loop), but - as
everyone who has attempted this seems to discover - replacing innerHTML
repeatedly in mozilla/gecko browsers causes an unacceptable flicker. IE
is smooth as silk. googled for some alternatives and they all exhibit
the same degree of suckage. Couldn't work around it, or find a bugzilla
track. Still playing around tho...

Jul 23 '05 #3
Dan wrote:
Hi

Does anyone know of a good Javascript typewriter ticker that allows
you to insert HTML into the ticker. I have found lots but when HTML is inserted, the ticker pauses at the point it reaches the HTML as well
as applying the formatting. I need one whose character timer ignores
characters in tags. I need to apply font color and weight styling to
different words.

Please see www.launchpr.co.uk for how the ticker currently looks in
Flash - it needs to be replaced with HTML/JavaScript which produces
the same effect.

Thanks in advance

Dan


OK, try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/str****ict.dtd" >
<html>
<head>
<title>untitled </title>
<style type="text/css">

body {
margin: 40px;
}
#typeSource {
display: none;
}
#typeWindow {
width: 635px;
font: bold 11px arial, tahoma, sans-serif;
color: #666;
border-top: 3px #eee solid;
border-bottom: 3px #eee solid;
}
..logoblk {
color: #000;
}
..logored {
color: #b00;
}
..cursorChar {
text-decoration: underline;
font-weight: bold;
color: #000;
}

</style>
<script type="text/javascript">

window.onload = function()
{
var startDelay = 2;
setTimeout(
'initTypewriter ("typeSource ", 40);',
startDelay * 1000);
}

</script>
<script type="text/javascript" src="typewriter .js">
</script>
</head>
<body>
<div id="typeWindow" >&amp;nbsp;</div>
<div id="typeSource" >
2005 so far...<br>
Ford appoints
<span class="logoblk" >LAUNCH</span><span class="logored" >PR</span>
for 6 month campaign to launch the all-new Ford Focus. Tesco hires
<span class="logoblk" >LAUNCH</span><span class="logored" >PR</span>
for Race<br>for Life and Computers for Schools campaigns, following
a hugely successful 2004 together.
<span class="logoblk" >LAUNCH</span><span class="logored" >PR</span>
gets in the<br>Irish spirit for Jameson Irish Whiskey.
Universal Pictures Video and The Sugar Bureau re-appoint agency for
2005<br>lifesty le campaigns.
<span class="logoblk" >LAUNCH</span><span class="logored" >PR</span>
supports official DEC Tsunami Earthquake appeal by donating agency time
to<br>fundraisi ng campaign.
</div>
</body>
</html>

[typewriter.js]

var sourceObj = null;
var typeWindow = null;
var message = '';
var typedPortion = '';
var cursorChar = '';
var cursorHTML = '<span class="cursorCh ar">@</span>';
var workHTML = '';

function initTypewriter( sourceId, newSpeed)
{
sourceObj = document.getEle mentById(source Id);
typeWindow = document.getEle mentById('typeW indow');
typeWindow.inne rHTML = '';
message = sourceObj.inner HTML;
msgLength = message.length;
HTMLstr = '';
workChar = '';
count = 0;
speed = newSpeed;
typing = setInterval('ty peText();', speed);
}

function typeText()
{
if (count == msgLength)
{
clearInterval(t yping);
return;
}
else if (count == 0)
typedPortion = '';
else
typedPortion = message.substri ng(0, count)
cursorChar = message.charAt( count);
if (/</.test(cursorCha r))
{
var tag = message.substri ng(count).match (/<\/?[^>]+>/);
if (tag)
{
typedPortion += tag[0];
count += tag[0].length;
}
}
else
{
workHTML = '';
workHTML += typedPortion;
if (count != msgLength - 1)
workHTML += cursorHTML.repl ace(/@/, cursorChar);
typeWindow.inne rHTML = workHTML;
count++;
}
}

Thanks to Peter Bailey (http://www.peterbailey.net) for his code, which
I lifted and sifted. Needs some work, but seems to be on the right
track. Shop it around to some different browsers if you get the chance.

Jul 23 '05 #4

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

Similar topics

1
4011
by: Tony Carnell | last post by:
Hi, I'm trying to source a (preferably free) JavaScript news ticker that does not carry adverts and will take its feed from an external text file or html page. Any advice or links would be greatly appreciated. Thanks in advance. Tony.
4
6058
by: dthelwal | last post by:
I'm looking for an applet or script to feed from an RSS page (perhaps RSS 0.91) and turn its <title> and <link> entries (perhaps using <description> as well) into a scrolling news ticker where the ticker will pause when you move your mouse over a news item and clicking on that item would jump to the hyperlink in the RSS page. There are a lot of simpler tickers out there and some even take basic XML format pages as their content source...
1
2103
by: David | last post by:
Hi, I have the following asp in my page, but I keep getting the following error Microsoft VBScript runtime error '800a0009' Subscript out of range: 'ticker' Please can you help me ?. Here is the page code I have so far: ---------------------------------
1
20171
by: paulnightingale | last post by:
Hi I've got a ticker tape that is written in Java Script 1.2 which displays text that has to be currently changed in the program code. What I want to do is to find the bit of javascript to get the program to read a text file so that the text file can be used to update the contents of the ticker tape. Preferably I will produce a bit of code that produces a window in which you type the text you want to display and then this gets saved as a...
2
4292
by: kevintan | last post by:
Hi all, Not sure whether you guys can help. Looking at both forms in javascript below: <html> <head> <script language="Javascript">
5
1814
by: mark4asp | last post by:
I need a row of tickertape. Each character should appear on screen as if it were being typed, so that the entire row is scrolled left to right. Like a 'teletype' - I think they were called. What am I doing wrong here? <http://www.sharemation.com/mark4asp/TickerTape.html> Q: What is the setting in IE 6 such that the browser automatically runs javascript without that nonsense asking the user whether they
9
3982
by: Mike | last post by:
I want to create a news/stock/sport ticker for my desktop. I want to have the ability to select my news source, (cnn, msnbc, etcs) sport source(espn, nfl, nba, etc) and my stock source (nasdaq, nyse, etc) then once that information is selected store it in a XML file, then have my ticker read that XML file to determine what service to use. I would like this to show the information for 10 seconds or so (just the headlines) then scroll UP...
1
1392
by: tgmurray | last post by:
I have created a small page using html and javascript that attempts to create a ticker. I am trying to go from 0 to 9 and then repeat itself. It should go to each new value after 1 second. Unfortunately, it simply displays 0 and hangs (shows hourglass in browser). I am running my page on XP Professional, using javacript. Code is as follows: <script type="text/javascript"> var x = 0;
3
2067
by: rassklass | last post by:
HI all, I have designed a site found at www.pickupnewspapers.co.uk/nottinghamshire/index.html but I cant get the footer to sit stil on the page. It is because of the javascript ticker, everytime the ticker types the footer jumps up and down. Also the ticker does not work in firefox but does in IE7 (cant test in any others as dont have a computer with it on) . I am quite amateur to html and no nothing about javascript. I am aware there are...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8780
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7378
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.