473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Simple Scrolling Text Box

I have been looking at a simple example of a scrolling text box (the one in
the SAM book) as below:

<script language="JavaScript">
var pos=100;
function Scroll() {
if (!document.getElementById) return;
obj=document.getElementById("thetext");
pos -=1;
if (pos < 0-obj.offsetHeight+130) return;
obj.style.top=pos;
window.setTimeout("Scroll();",30);
}
</script>
</head>
<body onLoad="Scroll();">
<h1>Scrolling Window Example</h1>
<p>This example shows a scrolling window created in DHTML. The window
is actually a layer that shows a portion of a larger layer.</p>
<div id="thewindow" style="position:relative;width:180;height:150;
overflow:hidden; border-width:2px; border-style:solid; border-color:red">
<div id="thetext" style="position:absolute;width:170;left:5;top:100" >
<p>This is the first paragraph of the scrolling message. The message
is created with ordinary HTML.</p>
<p>Entries within the scrolling area can use any HTML tags. They can
contain <a href="http://www.starlingtech.com/dhtml/">Links</a>.</p>
<p>There's no limit on the number of paragraphs that you can include
here. They don't even need to be formatted as paragraphs.</p>
<ul><li>For example, you could format items using a bulleted list.</li></ul>
<p>The scrolling ends when the last part of the scrolling text
is on the screen. You've reached the end.</p>
<p><b>[<a href="javascript:pos=100;Scroll();">Start Over</a>]</b></p>
</div>
</div>
</body>

Try as I might, I cannot modify this to make the text loop instead of stop
at the bottom, can somebody please give me the simple answer.

Jul 20 '05 #1
1 16653
Oz
To make it loop simply add

if (pos < 0-obj.offsetHeight+130) {
pos = 100;
};

<script language="JavaScript">
var pos=100;
function Scroll() {
if (!document.getElementById) return;
obj=document.getElementById("thetext");
pos -=1;
if (pos < 0-obj.offsetHeight+130) {
pos = 100;
};
obj.style.top=pos;
window.setTimeout("Scroll();",30);
}
</script>


"Midas NDT Sales" <sa***@midas-ndt.co.uk> wrote in message
news:10****************@iris.uk.clara.net...
I have been looking at a simple example of a scrolling text box (the one in the SAM book) as below:

<script language="JavaScript">
var pos=100;
function Scroll() {
if (!document.getElementById) return;
obj=document.getElementById("thetext");
pos -=1;
if (pos < 0-obj.offsetHeight+130) return;
obj.style.top=pos;
window.setTimeout("Scroll();",30);
}
</script>
</head>
<body onLoad="Scroll();">
<h1>Scrolling Window Example</h1>
<p>This example shows a scrolling window created in DHTML. The window
is actually a layer that shows a portion of a larger layer.</p>
<div id="thewindow" style="position:relative;width:180;height:150;
overflow:hidden; border-width:2px; border-style:solid; border-color:red"> <div id="thetext" style="position:absolute;width:170;left:5;top:100" >
<p>This is the first paragraph of the scrolling message. The message
is created with ordinary HTML.</p>
<p>Entries within the scrolling area can use any HTML tags. They can
contain <a href="http://www.starlingtech.com/dhtml/">Links</a>.</p>
<p>There's no limit on the number of paragraphs that you can include
here. They don't even need to be formatted as paragraphs.</p>
<ul><li>For example, you could format items using a bulleted list.</li></ul> <p>The scrolling ends when the last part of the scrolling text
is on the screen. You've reached the end.</p>
<p><b>[<a href="javascript:pos=100;Scroll();">Start Over</a>]</b></p>
</div>
</div>
</body>

Try as I might, I cannot modify this to make the text loop instead of stop
at the bottom, can somebody please give me the simple answer.

Jul 20 '05 #2

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

Similar topics

4
by: Cat Laugel | last post by:
Hello, I am redesigning my website and would like to have the text scroll within the webpage without the page itself scrolling.... if you understand what I mean... ;-) I want a very sleek look...
1
by: Dario de Judicibus | last post by:
I wish to create two simple layouts by using only HTML, CSS and the minimum JavaScript as possible. Layouts should be "elastic"/"liquid" (no fixed widths and heights) and cross-browser enabled. ...
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
5
by: Will Gillen | last post by:
I need to have a "scrolling" text label or textbox at the bottom of my window to show the URL of where a song is being played from. I want the text to scroll on a single line from left to right in...
17
by: pigeonrandle | last post by:
Hi, I have seen loads of different ways to do this, but the all seem to yield the same result - text that doesn't flicker when it's moving too slowly! Does anyone know 'the best way' to make text...
5
by: PythonistL | last post by:
I am a newbie with Javascript. I have this simple script for scrolling text <HTML> <HEAD> <TITLE>Scrolling Message Script</TITLE> <SCRIPT language="JavaScript"><!-- var msg = 'My scrolling...
5
by: PythonistL | last post by:
I have this script that scrolls the plain text. <script type="text/javascript"> var msg = 'My scrolling text. ..'; var myTimeout; function scrollMsg() {...
1
by: Thorsten Kleinweber | last post by:
Hello, I did some first steps in programming a site for a friend and have some questions concerning web design. The site is http://www.stevanez-juls.de: 1. On my tft display (with low...
3
by: Chamnap | last post by:
Hello everybody, I have one problem. I want to do something after the user finished scrolling. The scroll event fires whenever the user is scrolling. I don't want this actually. Does anyone has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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...
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
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,...
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...

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.