Jump to content

JavaScript working in IE but not in Firefox

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
sakishrist

sakishrist

    Programmer

  • Members
  • PipPipPipPip
  • 109 posts
Hello, I decided to begin learning some JS so my level is 'beginner', and now I faced a strange problem: my script works in IE (even if it first asks me to allow it) but it doesn't in firefox. Here is the script.
<html>


<head>

<style type='text/css'>

TH {text-align:right};SPAN {vertical-align:bottom};

</style>

<script language='JavaScript'>

var fifteenth = new Date();var sixteenth = 6;var seventeenth = 3;

function eighteenth() {	with(document.all) {		nineteenth.style.setExpression('width','fifteenth.getHours() * sixteenth * seventeenth','jscript');		twentieth.setExpression('innerHTML','fifteenth.getHours()','jscript');		first2.style.setExpression('width','fifteenth.getMinutes() * sixteenth','jscript');		second2.setExpression('innerHTML','fifteenth.getMinutes()','jscript');		third2.style.setExpression('width','fifteenth.getSeconds() * sixteenth','jscript');		fourth2.setExpression('innerHTML','fifteenth.getSeconds()','jscript')    }		fifth2();}

function fifth2() {	fifteenth = new Date();	document.recalc();	setTimeout('fifth2()',1000);}window.onload=eighteenth;

</script>




<title></title>


</head>


<body>



<TABLE BORDER=0><TR>	<TH>Hours:</TH>	<TD>

<SPAN ID='nineteenth' STYLE='background-color:red'></SPAN> 

<SPAN ID='twentieth'></SPAN></TD></TR><TR>

<TH>Minutes:</TH>	<TD>

<SPAN ID='first2' STYLE='background-color:yellow'></SPAN> 

<SPAN ID='second2'></SPAN></TD></TR><TR>

<TH>Seconds:</TH>	<TD>

<SPAN ID='third2' STYLE='background-color:#00FF40'></SPAN> 

<SPAN ID='fourth2'></SPAN></TD></TR></TABLE>

</body>


</html>

If I'm right firefox did not accept this: STYLE='background-color:red'
I got to this conclusion because I did some tests with the lines that have 'STYLE' (but I first deleted everything else to make sure it is not affected by the JScript) and IE accepts them but firefox does not show any colored areas at all.

#2
acwclassic

acwclassic

    Newbie

  • Members
  • PipPip
  • 25 posts
in firefox chose "preferences" then "web settings" and there you can enable javascript aswell as java.
and javascript isnt the same as java which is a high level programming language.
http://forum.codecal...javascript-css/

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I get the following errors:
nineteenth.style.setExpression is not a function
Non-standard document.all property was used. Use W3C standard document.getElementById() instead.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
CygnetGames

CygnetGames

    Programmer

  • Members
  • PipPipPipPip
  • 119 posts
One way to get around some of the incompatibilities between browsers (and make writing code easier) is to use a library like iQuery. While you might want to use document.all in IE, but document.getElementById() in FireFox, jQuery will work out for you which to use - you just use a single jquery function and your code works on different browsers.

#5
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Try fireBug. You can debug your scripts. The Web Developer toolbar might come in handy, too.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#6
jsoreno

jsoreno

    Newbie

  • Members
  • Pip
  • 3 posts
Java is such a big help for all this stuff. . I really want to know more about java. .

#7
satya5321

satya5321

    Newbie

  • Members
  • Pip
  • 8 posts
there is some specific syntax for CSS tags for IE(append # before element .class selector) and FireFox