PDA

View Full Version : How do I make those scrolling status bar messages?


SS2Trunks69
10-11-2002, 11:10 PM
I have a book called Creating Cool HTML 4 Web Pages 2nd Edition. I've learned a lot from it, and now I want to learn Javascript, which it does cover, but it doesn't work when I try it. And I went to a tutorial site yesterday and it had a COMPLETELY different method for the scrolling status bar message. So, anybody know an easy way to do it?

Mr J
10-11-2002, 11:22 PM
<script language="JavaScript">


scrollMsg = " Here is some scrolling text... "count = 0

function scrollIt() {
msgFront = scrollMsg.substring(count,scrollMsg.length)
msgBack = scrollMsg.substring(0,count)
window.status = msgFront + msgBack
if (count < scrollMsg.length)
count++
else
count = 0

setTimeout("scrollIt()",100)
}

</script>


Place onload="scrollIt()" in the opening <Body> tag

SS2Trunks69
10-11-2002, 11:27 PM
One last question. Where would I put what I want to scroll in the script you just posted? In between the () parenthesis? I'm pretty sure that's where it goes...but I just wanna make sure...

SS2Trunks69
10-12-2002, 12:21 AM
Ok wait, nevermind. I get it now. But it still isn't working. I put it EXACTLY like you did, except I might have left some capitals in lowercase. I don't know if that would really do anything though..

whammy
10-12-2002, 12:38 AM
Since javascript is case-sensitive, that would definitely make a difference. Just copy and paste the example shown.

One nice way to do that on here is to go to the post with the example code, and click on "edit". Since you're not a moderator, you won't actually be able to edit the post, BUT you can copy and paste the code from the provided textarea, which will keep the original formatting. :)

Besides, it's just good programming practice to consider case-sensitivity... what if later on you want to convert the script to another language?

:D

SS2Trunks69
10-12-2002, 12:49 AM
It is? Really??? That's weird. I mean, the book says you don't have to have HTML in all caps or use the quotes all the time, but it's good practice. But I never believed em. Now I do, though. Thanx man.

SS2Trunks69
10-12-2002, 12:53 AM
ARGH!!! It STILL doesn't work! What's going on with this crap? Geez...this is why nobody likes JavaScript...

Nightfire
10-12-2002, 01:09 AM
Show the page that you're having problems with. No one can help if they can't see what's wrong. Case sensitivety in htmldoesn't mater, can have <hTmL> if you want, doesn't matter :p In a programming language it does matter, like javascript

whammy
10-12-2002, 01:15 AM
Actually, it's good practice to code all your HTML tags and elements in LOWER case... i.e. <html></html>

That's all that XHTML (the newest version of HTML, for simplicity's sake) understands... not to mention it's easier... and it still works with all browsers, even old ones. It sounds like you have an old book. :D

And like NightFire said, if you don't post the script you're having problems with, and the problem you're having, we can't help.... since we have nothing to work with.

JavaScript is fun! :)

SS2Trunks69
10-12-2002, 01:23 AM
Well, I'm just testing it out in Notepad for now. Once I get it to work, I'm gonna put it in my site, but so far it's not working. Maybe it's just cuz Notepad doesn't support it?

whammy
10-12-2002, 01:24 AM
Let's see the code you're using... without showing us what you're trying to do, we have absolutely no way to answer your question, since there are potentially millions of things you could be trying... or after two different posts asking that you post your code, are you just trying to waste our time? :eek:

SS2Trunks69
10-12-2002, 06:02 AM
Nah man, sorry. I guess I read it wrong. I thought you said what am I using to make the site, meaning, what program, ya know? Anyway, I'm just tryin to get a scrolling message in the status bar, and I'm using the code that Mr J posted. I even copied and pasted and it still doesn't work, so I have no clue what's going on. And Notepad is the only program I have that edits HTML codes, so if it doesn't accept JavaScript, which I don't know why it wouldn't, then I'm basically screwed.:confused:

Mr J
10-12-2002, 12:55 PM
Ok the reason it will not work is because I made a typo .... DOH!

or this forum rendered the script wrong


Try this



<script language="JavaScript">
<!--

scrollMsg = " Here is some scrolling text... "

count = 0

function scrollIt() {
msgFront = scrollMsg.substring(count,scrollMsg.length)
msgBack = scrollMsg.substring(0,count)
window.status = msgFront + msgBack
if (count < scrollMsg.length)
count++
else
count = 0

setTimeout("scrollIt()",100)
}
// -->
</script>


Place onload="scrollIt()" in the opening <Body> tag






Just in case download the zip for a workin g copy :)

SS2Trunks69
10-13-2002, 04:14 AM
Hey thanks, man. I'll test em out and let ya know if they work.

IT WORKS!!!!

Sweet...:D

Only...how come it doesn't fill up the whole status bar? It only fills up like...I dunno, one 4th of it...

Mr J
10-13-2002, 10:24 AM
Short message?

Maybe

;)