473,408 Members | 2,027 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,408 software developers and data experts.

Flying text sinks to the bottom, does not rise to the top?

I write a flying text script,but it sinks at the bottom and it stays
there forever.

How to change it so that it flies in the webpage?

<html>
<head>
<title>Flying text</title>
<script type="text/javascript">
<!--
var dom, finalx=700, finaly=540;
function initText() {
dom=document.getElementById("theText").style;
var x=dom.left;
var y=dom.top;
x=x.match(/\d+/);
y=y.match(/\d+/);
moveText(x,y);
}
function moveText(x,y) {
if(x!=finalx)
if (x>finalx) x--;
else x++;
if(y!=finaly)
if (y>finaly) y--;
else y++;
if( (x!=finalx) || (y!=finaly)) {
dom.left=x+"px";
dom.top=y+"px";
}
setTimeout("moveText(" + x + "," + y + ")", 1);
}
//-->
</script>
</head>
<body onload="initText()" >
<p>
<span id="theText" style="position: absolute; left: 100px; top:
100px; font: bold 20pt 'Times Roman'; color: blue;">
Hello!
</span>
</p>
</body>
</html>

Jul 23 '05 #1
1 1745
al********@hotmail.com <ma*****@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I write a flying text script,but it sinks at the bottom and it stays
there forever.

How to change it so that it flies in the webpage?


You need to store the current x and y direction, increment the co-ordinates
accordingly and change directions when defined limits are reached.

<html>
<head>
<title>Flying text</title>
<script type="text/javascript">

var dom, finalY=screen.availHeight||screen.height,
finalX=screen.availWidth||screen.width, xDir=1, yDir=1;
finalY=Math.round(finalY*0.7);

function initText()
{
if( document.getElementById &&
(dom=document.getElementById("theText").style) )
{
var x=dom.left;
var y=dom.top;
x=x.match(/\d/);
y=y.match(/\d/);
moveText(x,y);
}
}

function moveText(x,y)
{

if( (xDir==1 && x>=finalX) || xDir==-1 && x<=0)
xDir=-xDir;

x+=xDir;

if( (yDir==1 && y>=finalY) || yDir==-1 && y<=0)
yDir=-yDir;

y+=yDir;

dom.left=x+"px";
dom.top=y+"px";

setTimeout("moveText(" + x + "," + y + ")", 50);
}

</script>
</head>

<body onload="initText()" >

<div id="theText" style="position: absolute; left: 100px; top:
100px; font: bold 20pt 'Times Roman'; color: blue;">Hello!</div>

</body>
</html>
--
Stephen Chalmers http://makeashorterlink.com/?H3E82245A


Jul 23 '05 #2

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

Similar topics

2
by: zwylle | last post by:
Hi all, to avoid a nervous breakdown I finally decided to seek help :D I have a table defined with plain color background and in some cells I show pictures to frame my site. The problem I...
1
by: Serge Shimanovsky | last post by:
Hi, I have a situation where I need to clear the event sinks from an event. But let's say I don't know which methods (by name, I mean) signed up for that event. I do have a control with...
0
by: Razzie | last post by:
Hey all, I'm... pretty stuck. I've created a ISmtpInCommand sink following this tutorial: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmtps/html/writingmngsinks.asp ...
6
by: Bosnewi | last post by:
hi, What's the easiest way to make a text to fly inside of any control such as textbox. Any ideas???
3
by: RobofNZ | last post by:
Hi Guy's, I'm a little new to the .NET enviroment but need to put together a custom sink chain for a mini project I've got.... The problem that I'm having is that the system needs to be more...
2
by: george.leithead | last post by:
Hi all, I have a very strange problem! In following Web page (which is generated from a CMS System), the navigation to the left 'dissapears' when you roll the mouse over the links? It does not...
9
panachepad
by: panachepad | last post by:
I arrived here from a websearch that found this thread from your archives: http://www.thescripts.com/forum/thread97805.html It helped me to understand that I am on the right track, but I still have...
3
by: kk.simhadri | last post by:
Hi, I want to align some text to the bottom of page.I am doing this by a CSS class.It contains position:absolute; bottom:0; this does the purpose. but when I resize my page to smaller...
0
by: JosAH | last post by:
Greetings, Introduction Last week I was a bit too busy to cook up this part of the article series; sorry for that. This article part wraps up the Text Processing article series. The ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
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...
0
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...

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.