473,382 Members | 1,743 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,382 software developers and data experts.

Dynamically change colors on a page

Hello,

I have a page that loads some color values from a database and then a javascript needs to replace the stylesheet classes. For example the stylesheet has:
Expand|Select|Wrap|Line Numbers
  1. .txt_content {color: #ffffff;}
and I want to change this to .txt_content {color: #000000;}

Then I call my script with changecss('.txt_content','color','#000000')

This works in FF, but not in IE. How do I solve this?
And another problem: how do I get it to change the hover pseudo-property of a link?

Here's the function:
Expand|Select|Wrap|Line Numbers
  1. function changecss(theClass,element,value) {
  2.   var cssRules;
  3.   if (document.all) {
  4.     cssRules = 'rules';
  5.   } else if (document.getElementById) {
  6.     cssRules = 'cssRules';
  7.   }
  8.   for (var S = 0; S < document.styleSheets.length; S++){
  9.     for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
  10.       if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
  11.         document.styleSheets[S][cssRules][R].style[element] = value;
  12.       }
  13.     }
  14.   }
  15. }

Tjeerd
Sep 8 '07 #1
1 1073
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

See if this page helps.

What happens in IE?
Sep 10 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Jan Tuxen | last post by:
Jakob Nielsen in his most recent Alertbox (http://www.useit.com/alertbox/20040503.html) tells web authors to change the color of visited links. I agree to his purpose: Help users understand...
9
by: pablo | last post by:
Dear NGers, I would like to change the alt-text with the changing of the image during a mouseover action. Can document.images.altView be changed dynamically? TIA, pablo
3
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 | +---+---+
4
by: codemonkey | last post by:
TIA! I would like to know if there is a way to dynamically change the colors of Subform items? I have already set in place Conditional Formatting so each row has an alernating color scheme, but...
5
by: Amelyan | last post by:
How can I get state of dynamically created controls (RadioButton, CheckBox, TextBox.Text) on post back when I click submit button? The only way I know is by traversing Response.Form enumberator;...
5
by: Arpan | last post by:
In order to populate any server control with data dynamically, is it ALWAYS NECESSARY to either BIND the DataSource to that server control or call the DataBind method of that server control? For...
8
by: miladhatam | last post by:
can i change the size of a file dynamically ? for example have 100 Kb and i want to decrease it to 20 Kb thanks
2
dmjpro
by: dmjpro | last post by:
i want change the color using R,G and B colors dynamically.. is there any function RGB .. or anything else ... plz help .. thanxxx in advance
2
by: kasem | last post by:
Hi... I need to change the background color of my webpage using xml file,so I can create an admin page where i give the admin options of different colors just by pressing a button....Do I have to...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.