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

Firefox & getElementById('main_txt') doesn't work

Howdy,

I've got here a sample of my function which is supposed to fade a
certain piece of text to another colour. This line is then located in a
for loop and it works pretty well in IE 6. However, in Firefox, and thus
I assume it will be the same in Netscape and Mozilla, it gives a problem
with the: getElementById('main_txt'). Due to that in setTimeout("",) it
requires the "" signes and thus I can not use the same ones in the
getElement part. IE has no problem with using '' in there, Firefox,
however, does. Can anyone think of how to get around this and make
firefox do this?

window.setTimeout("document.getElementById('main_t xt').style.color =
'rgb("+red+","+green+","+blue+")'",delay*step);

Thanks in advance, Maarten
Jul 23 '05 #1
1 3404
Muffinman wrote:
Howdy,

I've got here a sample of my function which is supposed to fade a
certain piece of text to another colour. This line is then located in a
for loop and it works pretty well in IE 6. However, in Firefox, and thus
I assume it will be the same in Netscape and Mozilla, it gives a problem
with the: getElementById('main_txt'). Due to that in setTimeout("",) it
requires the "" signes and thus I can not use the same ones in the
getElement part. IE has no problem with using '' in there, Firefox,
however, does. Can anyone think of how to get around this and make
firefox do this?

window.setTimeout("document.getElementById('main_t xt').style.color =
'rgb("+red+","+green+","+blue+")'",delay*step);


Let's end this misery:

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN'
'http://www.w3.org/TR/html4/strict.dtd'>
<html><head>
<title>f-f-f-fader</title>
<meta http-equiv='Content-Type'
content='text/html; charset=ISO-8859-1'>
</head>

<body onload="change_colour('xx','0','0','0');">

<script type="text/javascript">

function change_colour(ele,r,g,b){
var s = document.getElementById(ele);
var dest_red = 202;
var dest_green = 207;
var dest_blue = 222;
var lag = 500;
var steps = 10;

// Ensure values are numbers so can add to them
r = +r; g = +g; b = +b;

var steps_red = (dest_red - r)/steps;
var steps_green = (dest_green - g)/steps;
var steps_blue = (dest_blue - b)/steps;

// Start the timer
s.timer = window.setInterval(function() {
r += steps_red;
g += steps_green;
b += steps_blue;

// If we're at the end (or really close), finish it
if ( r > dest_red || g > dest_green || b > dest_blue) {
s.style.color = 'rgb('
+ dest_red + ','
+ dest_green + ','
+ dest_blue + ')';
s.innerHTML = '<b>I\'m done...</b>';

// Stop the timer
window.clearTimeout(s.timer);
s.timer = null;

} else {

// ensure values are integers
s.style.color = 'rgb('
+ Math.floor(r) + ','
+ Math.floor(g) + ','
+ Math.floor(b) + ')';

// Just to show the values as we go...
s.innerHTML += '<br>' + r + ', ' + g + ', ' + b;
}
}, lag);
}

</script>

<span id="xx" style="color: blue;"><b>HI TO EVERYONE</b></span>

</body>
</html>

--
Zif
Jul 23 '05 #2

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

Similar topics

12
by: vadivasbro | last post by:
Very simple code. Why won't this work? <html> <head> <script type="text/javascript"> window.onload = document.getElementById("thisThing").style.background = "red"; </script>
5
by: code_wrong | last post by:
Hi Firefox does not support the IE specific 'event' identifier and just quits running the script. ..... even though the identifier only turns up in code marked for IE only ... Does this seem...
18
by: Gustaf Liljegren | last post by:
IE does, and I can't remember this used to be a problem in Netscape. I guess someone in the Mozilla team just came up with a Smart Idea about the True Semantics of the Hyphen Minus character. :-(...
1
by: chaitatp | last post by:
Hi friends, I've got a problem about inserting Flash in iframe in Firefox. The codes are: ---- test.html ---- <html> <head> <script type="text/javascript"> function doBodyOnLoad()
14
by: xxbmichae1 | last post by:
I have a <select> object that i've set up an onchange event that fires in IE fine when I use the cursor up and down in the list, but If I use the cursor up and down in Firefox the event doesn't...
1
by: mike | last post by:
The JavaScript below works fine for expandable/collapsible menus in IE, but Firefox 1.5 complains: "Error: loc.parentNode.nextSibling has no properties" and highlights the line...
7
by: 80s.arcade | last post by:
Hi. Please take a look at this page: http://tinyurl.com/s2l8w In IE6, putting the mouse on each of the two items highlights the word in a blue (different image) and shows a tool tip. In...
2
by: Christina | last post by:
I have 2 list boxes - one to fill the second one based on the selection, or move all items. You can remove the selection (or all items) from the second one to place it back in the first one. I...
1
by: David Henderson | last post by:
I know 'disable-output-escaping' has been discussed in the past, but I can't put my finger on any of the threads to see if my current problem is addressed. Sorry for re-asking the question if it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.