Thanks s4ty for that. However, it hasn't solved it I'm afraid.
It still has a problem with the same line as before even using your replacement code block and the 'side' values beginning with an uppercase character.
First it complained about the '+' in
"margin"+side, so I removed that, but then it was back to complaining about an unidentified identifier instead, on the same line.
I was somewhat puzzled as to why my code originally worked before I added in the dynamic 'side' parameter, bearing in mind what you said about the CSS shorthand properties above. I think those are referring to when
reading the CSS values from the document, rather than when setting them because in the example in your quote, they are being used as selectors.
The following does work fine, but can't handle the dynamic positioning for left and right placement:
- function centerElement(divid)
{
divid = "#"+divid;
jQuery(divid).css({
top:'50%',
left: (((jQuery(window).width() - 940)/2)/2) + 'px',
margin-top:'-' + ( jQuery(divid).height() / 2 )+'px',
margin-left:'-' + ( jQuery(divid).width() / 2 )+'px'
});
}
jQuery(document).ready(function($) {
centerElement('lhs_adsense');
});
I think the problem is concerning the correct syntax to use to replace 'left' with the variable 'side', so that left or right can be passed as a parameter.
Thanks for your input.
Peter
A Linux Admin
Willing to help maintain Linux servers remotely for a tiny consideration into my Paypal account :-)