473,748 Members | 5,232 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JavaS cript">
var pos=100;
function Scroll() {
if (!document.getE lementById) return;
obj=document.ge tElementById("t hetext");
pos -=1;
if (pos < 0-obj.offsetHeigh t+130) return;
obj.style.top=p os;
window.setTimeo ut("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.starlingtec h.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="javascrip t:pos=100;Scrol l();">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 16692
Oz
To make it loop simply add

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

<script language="JavaS cript">
var pos=100;
function Scroll() {
if (!document.getE lementById) return;
obj=document.ge tElementById("t hetext");
pos -=1;
if (pos < 0-obj.offsetHeigh t+130) {
pos = 100;
};
obj.style.top=p os;
window.setTimeo ut("Scroll();", 30);
}
</script>


"Midas NDT Sales" <sa***@midas-ndt.co.uk> wrote in message
news:10******** ********@iris.u k.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="JavaS cript">
var pos=100;
function Scroll() {
if (!document.getE lementById) return;
obj=document.ge tElementById("t hetext");
pos -=1;
if (pos < 0-obj.offsetHeigh t+130) return;
obj.style.top=p os;
window.setTimeo ut("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.starlingtec h.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="javascrip t:pos=100;Scrol l();">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
6956
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 and would like to use little arrows that people could press to see more of the text rather than have a very long page.... How should I go about that? I use DW3. Can it be done???? Thanks for any info!! ;-)
1
2033
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. The first one is a non-scrollable page which contains a centered title and a centered division with automatic scrolling on overflow, that is: +---------------------+ | TITLE | | +--------------++ |
44
919
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 put either tag inside an HTML <TD> and have the same kind of scrolling effect. This would allow me to fill the screen and have the size of the scrolling box change on resize. Thanks in advance.
5
21698
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 case the URL is longer than the width of the textbox/text label. Is there a native way to do this in VB.NET?
17
4754
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 scroll... eg Override OnPain and OnPaintBackground Override WndProc
5
4267
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 text.. ' function scrollMsg(){
5
2029
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() { document.getElementById('textScroll').innerHTML = msg; msg = msg.substring(1,msg.length) + msg.substring(0,1); myTimeout = setTimeout(scrollMsg, 200); }
1
2481
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 brightness adjustment) the site is correctly bright but on some other monitors it's very dark, does somebody know why? 2. Does somebody know why scrolling the white text on black background is deforming the text? If I change the background to a brighter...
3
11754
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 any idea or trick of how to achieve this? Appreciate your ideas..... Thanks Chamnap
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9548
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
9249
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
8244
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...
1
6796
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
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
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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.