[thelist] Javascript and Safari problem, (document body problem?)

Austin Harris austin at dotmail.co.uk
Fri Nov 9 07:01:51 CST 2007


Afternoon all, not been on here for a long time...

Just starting to get my head round javascript but still getting in a muddle every now and then.

I am trying to get something working and thought I had it cracked, (works in IE 6, FF Mac and PC) but I can't get it to work on Safari 2 Mac, which is what the client uses of course.

I think the problem is this line;

document.body.style.background='#5a5a5a url(homeimages/'+imageNumber+'/'+finalWidth+'.jpg) no-repeat top center;';

The full function is;

function first(){
	document.body.style.background='#5a5a5a url(homeimages/'+imageNumber+'/'+finalWidth+'.jpg) no-repeat top center;';
	var position =textPosition(finalWidth,imageNumber);
	var h1MTop = position[0];
	var hRight = position[1];
	prevText = document.getElementById('textBox');
	prevText.style.marginTop = ''+h1MTop+'px';
	prevText.style.marginRight = ''+hRight+'px';
}

It's called via;
<body onload="first(imageNumber)" id="bodyNm">
(Which I guess could also be a problem??)

The imageNumber and finalWidth variables are coming through just fine but it doesn't show the background image.

There are small previous / next links on the page to scroll through the list of images as well, page elements are positioned dependent on which image is shown, this bit works fine, just not the image.

Any ideas?

The full page can be seen here;
<dev.gregfoto.com>

I know it is a huge page, (it gets your screen size and then sets a BG image to that after forcing the screen full size*).

(The site is very much aimed at top end agencies for advertising etc. so connection speeds not an issue.)


*I have argued the point before anyone says anything!

All the best, Austin



More information about the thelist mailing list