Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS Styling in Javascript for IE?

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Hi,

A always, these damn browsers don't play ball :( I have the following code that will change the background color of a link (flashing);

Code:
window.onload = function ()
{
	the_array = getElementsByClassName(document,'flashingtext');
	for (i = 0; i < the_array.length; i++) {
		setInterval('flashtext(' + i + ')', 500 );
	}
} 


function flashtext(the_element) {

	if (the_array[the_element].style.backgroundColor != start_color)   {
		the_array[the_element].style.backgroundColor = start_color;
	} else {
		the_array[the_element].style.backgroundColor = end_color;
	}
}

"the_array" is an array of all the elements that match my "class" I'm looking out for.

This works 100% perfectly in FF, Chrome and Safari... but not IE as always! I'm guessing its got to do with the way I'm trying to change the CSS:

Code:
the_array[the_element].style.backgroundColor = end_color;

...so maybe this isn't valid in IE:

Code:
.style.backgroundColor = end_color;

Can anyone suggest to me what I can do? I would imagine I need to add an extra conditional to check if its IE we are using, and then update it a slightly different way if thats the case.

TIA!

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top