/    Sign up×
Community /Pin to ProfileBookmark

text rotation problem

Hi,

i have seen this script on the website :
[url]http://javascript.internet.com/messages/text-rotater.html[/url]

and i need to apply diffetens style to each ‘textStr’.

I have try things that didn’t work (i’m a newbie…)
For exeample i want textStr[0] in red bold and textStr[1] yellow italic.
Do you think you can help me?

Thanks in advance

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@ExuroNov 25.2004 — I don't tend to like scripts from JavaScriptSource, so I wrote a new one instead:
<html>
<head>
<title>Text Rotation</title>
<style type="text/css">
<!--
[color=purple]/* This is the base style for the text rotator */
#textRotator {
font-size:1.5em;
text-align:center;
}[/color]
[color=blue]/* The following style correspond to the different text
messages, so you can set their styles individually */
.textMessage0 {
color:red;
font-weight:bold;
}
.textMessage1 {
color:yellow;
font-style:italic;
}
.textMessage2 {
color:green;
text-decoration:underline;
}[/color]
-->
</style>
<script type="text/javascript">
<!--
[color=red]// Set the text messages
var textMessages = [
"This should be red and bold",
"This should be yellow and italic",
"This should be green and underlined"
];[/color]
// Set the delay time between the rotations (it's in miliseconds!)
var ROTATE_DELAY = 2000;
// Don't edit anything after this
onload = new Function("rotateText(0)");
function rotateText(msgNum) {
var textDisplay = document.getElementById("textRotator");
textDisplay.replaceChild(document.createTextNode(textMessages[msgNum]),textDisplay.firstChild);
textDisplay.className = "textMessage"+msgNum;
if (++msgNum >= textMessages.length) {
msgNum = 0;
}
setTimeout("rotateText("+msgNum+")",ROTATE_DELAY); <br/>
}
--&gt;
&lt;/script&gt;
&lt;body&gt;
&lt;div id="textRotator"&gt;&amp;amp;nbsp;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

The styles are manipulated through CSS classes, so just edit the class that corresponds to each text message's index. You can of course add more messages, or remove some, but you'd have to add/remove CSS classes too. Anyway, I hope that helps!
Copy linkTweet thisAlerts:
@timideauthorNov 26.2004 — thank your for your script! it works on IE, netscape, firefox :-)

i don't understand everything ...

where i must put a link for this rotate text (same link for the three texts) ?

(sorry for english)
Copy linkTweet thisAlerts:
@timideauthorNov 26.2004 — can i do this:

<a href="http://www.google.com/"><div id="textRotator">&nbsp;</div></a> ?
Copy linkTweet thisAlerts:
@ExuroNov 26.2004 — Yeah, that should work. You've probably already tried it by now though and figured that out. ?

[i]Edit:[/i]

I just realized though, that you're putting a [FONT=courier new]<div>[/FONT] within an [FONT=courier new]<a>[/FONT] tag, which is technically invalid. It would be simpler if you just gave the link the ID:
&lt;a id="textRotator" href="http://www.google.com/"&gt;&amp;amp;nbsp;&lt;/a&gt;
×

Success!

Help @timide spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...