S
shafiqrao
Hello everyone,
I have a script that runs in IE great, but in firefox it has problems.
I understand that there are some objects that are accessed differently
in IE and Mozilla. Can anybody let me know what I need to change in the
file to make a copy that would run fine on Firefox?
Here is the link to the file:
http://people.emich.edu/srehman2/study/polls.html click on the 'Build
Bars' link displayed at the top-right corner. I am copying the source
code here also,
=========================================================
<script language="javascript">
function BuildResults()
{
var str;
var imageWidths = new Array();
var imageName = new Array();
var labelName = new Array();
var imageSize = 140;
var BarImage = "images/poll_yellow.gif";
var t = new Array();
var color = new Array();
t[0] = 60;
t[1] = 30;
t[2] = 50;
t[3] = 112;
color[0] = 'red';
color[1] = 'blue';
color[2] = 'silver';
color[3] = 'green';
str = str + '<table cellspacing=2 cellpadding=0 border=0><tr><td>';
for(var i=0;i<t.length;i++)
{
imageWidths = Math.round(imageSize * (Math.round(t)/100));
imageName = "imageResult" + i;
labelName = "spanPercentage" + i;
str = str + '<table cellspacing=2 cellpadding=0 border=0 height=4>';
str = str + '<tr><td bgcolor=' + color + '><img name=' +
imageName + ' id=' + imageName + 'src="images/pixel.gif" width=1
height=1 border=0></td><td><span id=' + labelName + '>' +
Math.round(t) + '%</span></td></tr>';
str = str + '</table>';
}
str = str + "</td></tr></table>";
document.getElementById('divText').innerHTML = str;
for(var x = 0; x< imageWidths.length; x++)
{
var name = "imageResult" + x;
var image = document.getElementById(imageName[x]);
setTimeout("Wait()", 10);
if(image != null)
{
for(var i = 0; i <= imageWidths[x]; i++)
{
string = "IncreaseSize("+i+", '"+imageName[x]+"', '" +
labelName[x]+"', '" + imageSize + "')";
setTimeout(string, 40 * i);
}
}
}
}
function Wait()
{
//Wait for a second
}
function IncreaseSize(Size, ImageName, LabelName, ImageSize)
{
var image = document.getElementById(ImageName);
var label = document.getElementById(LabelName);
if(image != null)
{
image.width = Size;
image.height = 1;
label.innerHTML = Math.round((Size/ImageSize) * 100) + "%";
}
}
</script>
<span style="cursor: pointer; text-decoration: underline"
onclick="BuildResults()">
Build bars
</span>
<span name="divText" id="divText"></span>
=========================================================
It displays bars in IE but in firefox it do not display anything.
Thanks in advance.
-Shafiq.
I have a script that runs in IE great, but in firefox it has problems.
I understand that there are some objects that are accessed differently
in IE and Mozilla. Can anybody let me know what I need to change in the
file to make a copy that would run fine on Firefox?
Here is the link to the file:
http://people.emich.edu/srehman2/study/polls.html click on the 'Build
Bars' link displayed at the top-right corner. I am copying the source
code here also,
=========================================================
<script language="javascript">
function BuildResults()
{
var str;
var imageWidths = new Array();
var imageName = new Array();
var labelName = new Array();
var imageSize = 140;
var BarImage = "images/poll_yellow.gif";
var t = new Array();
var color = new Array();
t[0] = 60;
t[1] = 30;
t[2] = 50;
t[3] = 112;
color[0] = 'red';
color[1] = 'blue';
color[2] = 'silver';
color[3] = 'green';
str = str + '<table cellspacing=2 cellpadding=0 border=0><tr><td>';
for(var i=0;i<t.length;i++)
{
imageWidths = Math.round(imageSize * (Math.round(t)/100));
imageName = "imageResult" + i;
labelName = "spanPercentage" + i;
str = str + '<table cellspacing=2 cellpadding=0 border=0 height=4>';
str = str + '<tr><td bgcolor=' + color + '><img name=' +
imageName + ' id=' + imageName + 'src="images/pixel.gif" width=1
height=1 border=0></td><td><span id=' + labelName + '>' +
Math.round(t) + '%</span></td></tr>';
str = str + '</table>';
}
str = str + "</td></tr></table>";
document.getElementById('divText').innerHTML = str;
for(var x = 0; x< imageWidths.length; x++)
{
var name = "imageResult" + x;
var image = document.getElementById(imageName[x]);
setTimeout("Wait()", 10);
if(image != null)
{
for(var i = 0; i <= imageWidths[x]; i++)
{
string = "IncreaseSize("+i+", '"+imageName[x]+"', '" +
labelName[x]+"', '" + imageSize + "')";
setTimeout(string, 40 * i);
}
}
}
}
function Wait()
{
//Wait for a second
}
function IncreaseSize(Size, ImageName, LabelName, ImageSize)
{
var image = document.getElementById(ImageName);
var label = document.getElementById(LabelName);
if(image != null)
{
image.width = Size;
image.height = 1;
label.innerHTML = Math.round((Size/ImageSize) * 100) + "%";
}
}
</script>
<span style="cursor: pointer; text-decoration: underline"
onclick="BuildResults()">
Build bars
</span>
<span name="divText" id="divText"></span>
=========================================================
It displays bars in IE but in firefox it do not display anything.
Thanks in advance.
-Shafiq.