473,626 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Random scrolling text

Hy

I want to add a sort of news service to my site. I've a number of
messages, wich I want to be shown in a <marquee> tag. I've found a
simple scrit that generates an random message (wich I've putted in an
array) and the message is shown in an marquee tag. The problem is that
for changing the message, a reload of the page is required. Isn't
there a way to reload the message? Or every time the marquee tag shows
a message, it will be a differrent message? Or perhaps not using the
marquee tag, but another way to scroll text trough a page?

Thanxs in advance
Sven Daems

<SCRIPT LANGUAGE = "JavaScript ">

// The Array Function

function makeArray(len) {
for (var i = 0; i < len; i++) this[i] = null;
this.length = len;
}

// This is where the array of text/images/sounds is created.

ideas = new makeArray(22);
ideas[0] = "Message1"
.....
ideas[21] = "Message22"
// The random number generator.

function rand(n) {
seed = (0x015a4e35 * seed) % 0x7fffffff;
return (seed >> 16) % n;
}

var now = new Date()
var seed = now.getTime() % 0xffffffff

</SCRIPT>
</head>
--------------------------------------------
<body background="ima ges/midden_top.jpg" >
<marquee>
<SCRIPT LANGUAGE = "JavaScript ">

// Where you place this is where the random object will be displayed.

document.write( ideas[rand(ideas.leng th)])

</SCRIPT>
</marquee>

May 30 '06 #1
1 4269
sv********@gmai l.com wrote:
Hy

I want to add a sort of news service to my site. I've a number of
messages, wich I want to be shown in a <marquee> tag. I've found a
The marquee element is not part of the W3C HTML 4 specification, it is
supported in varying degrees by many browsers but it is likely that
there are some that don't support it at all.

MozDev:
<URL:http://developer.mozil la.org/en/docs/HTML:Element:ma rquee>

MSDN:
<URL:http://msdn.microsoft. com/workshop/author/dhtml/reference/objects/marquee.asp>

simple scrit that generates an random message (wich I've putted in an
array) and the message is shown in an marquee tag. The problem is that
for changing the message, a reload of the page is required. Isn't
there a way to reload the message? Or every time the marquee tag shows
a message, it will be a differrent message? Or perhaps not using the
marquee tag, but another way to scroll text trough a page?
The link above will tell you most of that, but again, support is likely
to be patchy.

<SCRIPT LANGUAGE = "JavaScript ">
The language attribute is deprecated, type is required:

<script type="text/javascript">

// The Array Function

function makeArray(len) {
for (var i = 0; i < len; i++) this[i] = null;
this.length = len;
}
That is a totally useless function. Use the in-built JavaScript array
object.

// This is where the array of text/images/sounds is created.

ideas = new makeArray(22);
ideas[0] = "Message1"
.....
ideas[21] = "Message22"
Seems much easier to use:

ideas = [
"Message 1",
"Message 2",
"Message 3",
...
"Message n"
];

// The random number generator.

function rand(n) {
seed = (0x015a4e35 * seed) % 0x7fffffff;
return (seed >> 16) % n;
}
Why not use Math.random? For this exercise, it doesn't seem that a
separate random number function is required anyway. A 'get next random
message' function might look something like:

function getRandMsg(msgA rray){
var rn = Math.random()*m sgArray.length | 0;
return msgArray[rn];
}
[...]
document.write( ideas[rand(ideas.leng th)])


Calling document.write after the page is loaded will clear the entire
page before writing new content. Use DOM or innerHTML to write new
content for the element.

Search the archives for scrolling banners that don't use a marquee
element. I find them very annoying, they are little used - I suspect
many others find them annoying too.
--
Rob
May 30 '06 #2

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

Similar topics

1
16681
by: Midas NDT Sales | last post by:
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;
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.
1
3603
by: Wesman | last post by:
Threads, textboxes and scrolling Thanks in advance for any information on this matter. I have run into a small richtextbox, scrolling and tread issue. Which has me totally confused. Instead of trying to explain it I wrote some small C# code to demonstrate the fact that in the threaded version the textbox simple doesn't scroll like it should… please look to the startButton_Click method for the distinction between the two programs..
5
21681
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?
2
2955
by: P2P | last post by:
Hi I am wondering if someone know of a free cross-browsers vertical scrolling script that - is cross cross-browsers - will call the scrolling content from an external html page or from a url page
4
7772
by: Keith Bentrup | last post by:
Hi all, I wrote a simple search function to find text in a textarea where not all the text is visible (ie. the text box displays 10 lines but there may be more than 1000 lines to search). I can find the text and select it using the function below, BUT I can't figure out how to have the textarea automatically scroll to the selection in Firefox. Any ideas or suggestions? function search(needle,haystack,start) { var element =...
4
2746
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. It should put a blue and yellow box on the page with "This is a test" as part of the picture. But what I get is a broken Gif. The other problem is that I can't view the source???? The view source is disabled for this page. What causes this?
5
4244
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(){
0
8259
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
8637
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8358
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8502
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
7188
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
6119
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
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1504
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.