I am not totally a novice, but only have self-trained experience. I am looking for a way to randomly change the background color and text color with my web pages. My thought is to put a counter on my home page and every even number on the counter the background color will be yellow and every odd number the colors will change to something else. If there4 is a script for this I would be truly grateful to learn how this would work. I have posted on the CSS/HTML forum with a similar question.
Thanks for any help that can be provided.
5 1902
I would prepare an array with allowed background colors and I would use Math.random * sizeOfArray on each page load to get index to that array, took and set color from it.
This way you can keep reasonable bg colors (pseudo) randomly selected.
I would prepare an array with allowed background colors and I would use Math.random * sizeOfArray on each page load to get index to that array, took and set color from it.
This way you can keep reasonable bg colors (pseudo) randomly selected.
I am very new to js what is math.ramdom
You can find detailed information about Math object (beware, case matters) here.
There is a lot of other useful information on the main site of that link.
You can find detailed information about Math object (beware, case matters) here.
There is a lot of other useful information on the main site of that link.
I found a site with the math.object and many other scripts. I may have to learn JS. I do have a question as far as where I can insert the code. If I set up a script to run like you say. Can I insert it in the Style tag under the body property as a value. In other words ti might look like this:
<style> body background: <script>bgcolor .js</script>; </style>
I know that this code is not exactly correct, but will this work is the file is called correctly.
acoder 16,027
Recognized Expert Moderator MVP
I found a site with the math.object and many other scripts. I may have to learn JS. I do have a question as far as where I can insert the code. If I set up a script to run like you say. Can I insert it in the Style tag under the body property as a value. In other words ti might look like this:
<style> body background: <script>bgcolor .js</script>; </style>
I know that this code is not exactly correct, but will this work is the file is called correctly.
No that's incorrect. See this link which describes where to put your Javascript scripts.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Scott |
last post by:
There is a setting in IE for "Print background colors and images."
I've noticed that without checking this option, a web page will print CSS
lines between table rows, but a background color of say the header won't.
The below style will display the borders in print preview, but won't display
the background color.
Does anyone know if it's possible to force background CSS or HTML colors to
print without having the user change the default...
|
by: Virus |
last post by:
Ok well what I am trying to do is have
1.) the background color to change randomly with 5 different colors.(change
on page load)
2,) 10 different quotes randomly fadeing in and out in random spots on the
webpage. with a delay timer on them, so they keep changing as the page is
open. Not random each time the page is loaded.
If anyone can help it would be greatly appreaciated, I have tried many of
|
by: Neal |
last post by:
According to the CSS lint at http://htmlhelp.org/tools/csscheck/, "The
shorthand background property is more widely supported than
background-color." Can anyone point me to, or provide, information on what
browsers have difficulty with the non-shortcut methods of setting
background properties?
|
by: Peter Williams |
last post by:
Hi All,
I want to write some javascript for a html page which does the
following.
Imagine that the page contains a table with 2 columns and 3 rows, e.g.:
+---+---+
| A | B |
+---+---+
|
by: J. B. Moreno |
last post by:
I read the faq, and it mentions that IE 4 on windows requires setting a
printing option to allow background colors to be printed.
Things change, life goes on, other browsers come into existence....
So, is there a way in CSS to say "Yeah, print these background colors",
without the user having to turn on an option that will then apply to all
pages printed?
Thanks,
| |
by: Franklin |
last post by:
WITHOUT KNOWING ANYTHING ABOUT THE CURRENT COLORS, I want to swap the
foreground/background colors of a link when someone hovers over it. Is
this possible with HTML, CSS, DOM, & JavaScript? If so, how?
See my HTML below (or go to my test page at
http://fmbbowen.com:39353/misc/Misc.html). I also tried treating
..color as a number and subtracting the current color from 0xFFFFFF but
that did not work either. The numerous examples I...
|
by: Bob Bedford |
last post by:
I've a table in wich I've this CSS:
..oddrow{background-color:#FFFFFF}
..evenrow{background-color:#CCCCCC}
The oddrows are white and the even are grey.
BUT ! when I do print the table, there is nothing !!!
How to print such lines colors ? the main purpose of this table is to be
|
by: Adam Hartshorne |
last post by:
Hi All,
I was wondering if somebody could post a few lines of code which would
produce random colors, which will be used in defining different regions
on a mesh. So in addition to having n random colors, I feel that there
should also be some condition to ensure that they aren't too similar in
appearance, given that is likely to range from 2-20 say.
Any help much appreciated,
|
by: shapper |
last post by:
Hello,
How can add a background color to each table cell in a table header
and also add a small image on the bottom right corner of each of those
cells?
Thanks,
Miguel
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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...
|
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,...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |