Re: Javascript doesn't work in Firefox
- From: "Trevor L." <tandcl@xxxxxxxxxxxxxxx>
- Date: Sat, 7 Jan 2006 16:18:08 +1100
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
.
- Follow-Ups:
- Re: Javascript doesn't work in Firefox
- From: Dr John Stockton
- Re: Javascript doesn't work in Firefox
- References:
- Javascript doesn't work in Firefox
- From: Trevor L.
- Re: Javascript doesn't work in Firefox
- From: Dave Anderson
- Re: Javascript doesn't work in Firefox
- From: Trevor L.
- Javascript doesn't work in Firefox
- Prev by Date: Re: Javascript doesn't work in Firefox
- Next by Date: Re: Need help getting iframe window size
- Previous by thread: Re: Javascript doesn't work in Firefox
- Next by thread: Re: Javascript doesn't work in Firefox
- Index(es):
Relevant Pages
|