473,756 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript, works good in IE but in Firefox Mozilla it gives problems

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="javas cript">
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><t d>';
for(var i=0;i<t.length; i++)
{
imageWidths[i] = Math.round(imag eSize * (Math.round(t[i])/100));
imageName[i] = "imageResul t" + i;
labelName[i] = "spanPercentage " + i;
str = str + '<table cellspacing=2 cellpadding=0 border=0 height=4>';
str = str + '<tr><td bgcolor=' + color[i] + '><img name=' +
imageName[i] + ' id=' + imageName[i] + 'src="images/pixel.gif" width=1
height=1 border=0></td><td><span id=' + labelName[i] + '>' +
Math.round(t[i]) + '%</span></td></tr>';
str = str + '</table>';

}
str = str + "</td></tr></table>";
document.getEle mentById('divTe xt').innerHTML = str;
for(var x = 0; x< imageWidths.len gth; x++)
{
var name = "imageResul t" + x;
var image = document.getEle mentById(imageN ame[x]);

setTimeout("Wai t()", 10);
if(image != null)
{
for(var i = 0; i <= imageWidths[x]; i++)
{
string = "IncreaseSize(" +i+", '"+imageName[x]+"', '" +
labelName[x]+"', '" + imageSize + "')";
setTimeout(stri ng, 40 * i);
}
}
}
}
function Wait()
{
//Wait for a second
}

function IncreaseSize(Si ze, ImageName, LabelName, ImageSize)
{
var image = document.getEle mentById(ImageN ame);
var label = document.getEle mentById(LabelN ame);

if(image != null)
{
image.width = Size;
image.height = 1;
label.innerHTML = Math.round((Siz e/ImageSize) * 100) + "%";
}
}
</script>
<span style="cursor: pointer; text-decoration: underline"
onclick="BuildR esults()">
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.

Apr 3 '06 #1
12 2082
sh*******@gmail .com said on 04/04/2006 7:07 AM AEST:
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="javas cript">
The language attribute is deprecated, type is required:

<script type="text/javascript">

function BuildResults()
{
var str;
var imageWidths = new Array();
When posting code, use spaces for indentation rather than tabs, with 2
or 4 spaces per level.

You can initialise an array with:

var imageWidths = [];

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;
You can initialise this array as:

var t = [60, 30, 50, 112];

color[0] = 'red';
color[1] = 'blue';
color[2] = 'silver';
color[3] = 'green';
And this one:

var color['red', 'blue', 'silver', 'green'];

str = str + '<table cellspacing=2 cellpadding=0 border=0><tr><t d>';
for(var i=0;i<t.length; i++)
{
imageWidths[i] = Math.round(imag eSize * (Math.round(t[i])/100));
imageName[i] = "imageResul t" + i;
labelName[i] = "spanPercentage " + i;
str = str + '<table cellspacing=2 cellpadding=0 border=0 height=4>';
str = str + '<tr><td bgcolor=' + color[i] + '><img name=' +
imageName[i] + ' id=' + imageName[i] + 'src="images/pixel.gif" width=1 ----------------------^^-----------------^^^

You have not quoted the value of the id attribute and there is no
whitespace bewteen the end of the value and the start of the name of the
src attribute, so the HTML looks like:

... id='imageResult 0src="images/pixel.gif"' ...

It is always a good idea to quote attributes even when not strictly
necessary. Inserting a space before the src attribute fixes the problem
for now...

If you use a strict doctype, Firefox will show the changing percentages
but not the growing bars. Trip it into quirksmode (remove any reference
to doctype) and you'll see the same results as IE.

Investigate these issues in a CSS forum:

news:comp.infos ystems.www.authoring.stylesheets

Incidentally, a much more efficient result could be achieved by using
divs for the bars and simply modifying their style attributes, there is
absolutely no need to generate a mass of nested tables every single time.

height=1 border=0></td><td><span id=' + labelName[i] + '>' +
Math.round(t[i]) + '%</span></td></tr>';
Don't allow posted code to auto-wrap, manually wrap it at about 70
characters to allow for a few replies.
[...] setTimeout("Wai t()", 10); [...]
function Wait()
{
//Wait for a second
}


How do you intend to do that?
[...]
--
Rob
Group FAQ: <URL:http://www.jibbering.c om/FAQ>
Apr 4 '06 #2
IE 5+ is what 95 per cent of paying cutomers use. Who cares what
FireFox, Netscape or Opera does. Go for the winner!

Apr 4 '06 #3
el*********@ele ctrician.com wrote:
IE 5+ is what 95 per cent of paying cutomers use. Who cares what
FireFox, Netscape or Opera does. Go for the winner!

Are you replying to something, or simply trolling?

--
Ian Collins.
Apr 4 '06 #4
el*********@ele ctrician.com wrote:
IE 5+ is what 95 per cent of paying cutomers use. Who cares what
FireFox, Netscape or Opera does. Go for the winner!


Here is the newsgroup troll again: electrician.

If memory serves me well you were the one giving very bad code with hundreds
of validationerror for that embedded video script, right?

I am still waiting for you to respond to that, 'electrician'.

And because I am today in a very trollable mood, I might also add:
"IE5/6 are both broken, don't code for them, don't use them!"

Maybe you better stick with pulling electrical wires, you are probably good
at that, and let the the programmers give advise about programming, ok?

Why-oh-why do I take that bait? :P

Regards,
Erwin Moller
Apr 4 '06 #5
Awesome Rob, you have solved my problem.

I am not a javascript programmer, but I knew some javascript some years
back ... thats why you might see my code is old fashioned and slow may
be.

I would think into changing the code to implement divs and changing its
style properties (I guess you mean width by that)

for function Wait(), this function is doing nothing i guess, I will
remove it also when I will be purifying my code for efficiency.

Once again, thanks for the help .. I really appriciate your detailed
and informative reply!

-Shafiq.

Apr 4 '06 #6
Ian Collins said the following on 4/4/2006 2:34 AM:
el*********@ele ctrician.com wrote:
IE 5+ is what 95 per cent of paying cutomers use. Who cares what
FireFox, Netscape or Opera does. Go for the winner!

Are you replying to something, or simply trolling?


He's trolling again. But, you knew that :)

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 4 '06 #7
Erwin Moller said the following on 4/4/2006 7:27 AM:
el*********@ele ctrician.com wrote:
IE 5+ is what 95 per cent of paying cutomers use. Who cares what
FireFox, Netscape or Opera does. Go for the winner!
Here is the newsgroup troll again: electrician.

If memory serves me well you were the one giving very bad code with hundreds
of validationerror for that embedded video script, right?

I am still waiting for you to respond to that, 'electrician'.

And because I am today in a very trollable mood, I might also add:
"IE5/6 are both broken, don't code for them, don't use them!"

Maybe you better stick with pulling electrical wires, you are probably good
at that, and let the the programmers give advise about programming, ok?


If he pulls wires like he programs, I wouldn't even want him pulling
wires :)
Why-oh-why do I take that bait? :P


Because it's so much fun f**king with a moron :)

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 4 '06 #8
electrician,

I am going for the winner, FireFox is gaining market share IE is losing
it. More and more serious companies have firefox as their standard web
browser. Even some SIG conferences have FireFox as official browser and
they recommend it.

this was about its winning, it is more efficient and secure than IE, It
provides more features to users than IE. Altough opera is even more
efficient than FireFox

that was about its functionality, Now try to open
http://internetexplorer.com they even do not have their matching name
website ... lol

there is more, but google is there for your answers ... I have spent
enough time.

Apr 4 '06 #9
el*********@ele ctrician.com wrote:
IE 5+ is what 95 per cent of paying cutomers use. Who cares what
FireFox, Netscape or Opera does. Go for the winner!

Except that IE customers *don't* pay - it comes with Windoze (and
Microsoft pays, as fines to the EU. Again).

Also, according to MarketShare who do a wonderful thing called actually
*counting* who uses what, IE accounts for only 84% of browser use and is
dropping like a stone!

Of course, there are other people who count usage, such as Janco
Associates (IE, 82%) or Best Practice.com (IE 79%), but the general
figure is pretty well agreed at around the 80% to 85% mark.

Trolls like yourself do nothing but highlight the dramatically falling
market share of Microsoft's frankly dreadful browser. So keep it up!!
Apr 4 '06 #10

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

Similar topics

11
3432
by: minnesotti | last post by:
Hi there, I subscribed to a photographic pictures-hosting website which is heavy on JavaScript. My preferred latest browser Mozilla Firefox does not work with it -- no pictures are displayed and no buttons react to clicking. The website's helpdesk says it should work with Firefox, and could not offer any more advices. The JavaScript Console shows that there are numerous errors occuring. It looks like the web browser does not recognise...
8
1928
by: Matt Kruse | last post by:
http://news.zdnet.com/2100-1009_22-6121608.html Hackers claim zero-day flaw in Firefox 09 / 30 / 06 | By Joris Evers SAN DIEGO--The open-source Firefox Web browser is critically flawed in the way it handles JavaScript, two hackers said Saturday afternoon. An attacker could commandeer a computer running the browser simply by crafting a Web page that contains some malicious JavaScript code, Mischa Spiegelmock and Andrew Wbeelsoi...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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,...
1
9843
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,...
0
8713
agi2029
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...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5142
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...
1
3805
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
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
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...

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.