Re: Javascript doesn't work in Firefox



Trevor L. wrote:
> I have read here that in-line styles should be avoided and moved to
> CSS wherever possible, but because this is done in JS, it could be
> one of those that are not possible (or at least not convenient) to
> move !

The code wasn't all in JS but I added in-line styles

> I will work on the suggetsions you have given.

After some experimentation using both IE6 and FF, I now have Firefox (and
IE6) working OK. There must be a different, perhaps stricter, version of JS
used by Firefox as I kept getting code that worked in IE6 and wouldn't work
in FF. And not just the background property.

This code:
function getPic()
{
with (document)
{
title = cap
// set table styles
getElementById("picname").style.background = 'url(' + pic + ')'
getElementById("picname").style.height = height + "px"
getElementById("picname").style.width = width + "px"

// set width of table cell "tc" = Row1 Col2
getElementById("tc").style.width = (width - 40) + "px"

// set height of table cell "mc" = Row2 Col1/2/3
getElementById("mc").style.height = (height -40)+ "px"
}
}
set the style.height to 76 (height passed is 500), although the width looked
OK

I had to change it to this to get it to work:
function getPic()
{
var cwidth = width - 40
var cheight = height - 40
with (document)
{
title = cap
// set table styles
getElementById("picname").style.background = 'url(' + pic + ')'
getElementById("picname").style.height = height + "px"
getElementById("picname").style.width = width + "px"

// set width of table cell "tc" = Row1 Col2
getElementById("tc").style.width = cwidth + "px"

// set height of table cell "mc" = Row2 Col1/2/3
getElementById("mc").style.height = cheight + "px"
}
}

I don't know whether this is worth following up, or whether it is of use to
other readers. It seems to imply (in Firefox, anyway) that when one uses
with (document) - or a similar construct - that one shouldn't alter a
variable that is not a property of document.

Perhaps document.width and document height exist - seems likely - and I
should have avoided using the same name!!

Only guessing
--
Cheers,
Trevor L.
Website: http://tandcl.homemail.com.au


.



Relevant Pages

  • Re: Open window - staus bar
    ... Trevor L. wrote: ... in IE6, ... in Firefox, I get a status bar ...
    (microsoft.public.scripting.jscript)
  • Re: New Trojan?
    ... > does he remember if he used IE6 or Firefox. ... Identical results on IE6 and Firefox. ... > Ethical Hacking at the InfoSec Institute. ... > pen testing experience in our state of the art hacking lab. ...
    (Security-Basics)
  • Re: New Trojan?
    ... > does he remember if he used IE6 or Firefox. ... Identical results on IE6 and Firefox. ... > Ethical Hacking at the InfoSec Institute. ... > pen testing experience in our state of the art hacking lab. ...
    (Security-Basics)
  • Re: firefox1.5
    ... I've gone to Avant broswer and I've also tried Maxthon. ... FF is cool and I do like the password-remember feature as well as ... Firefox also has its downsides. ... I found FF to be slower and to use a bit more memory than IE6. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: New Trojan?
    ... > does he remember if he used IE6 or Firefox. ... Identical results on IE6 and Firefox. ... to facilitate one-on-one interaction with one of our expert instructors. ... Attend a course taught by an expert instructor with years of in-the-field ...
    (Security-Basics)