The following JavaScript will allow the "width" style for spans to work in
all browsers, regardless of DOCTYPE:
<script type="text/javascript" >
var sps = document.getElementsByTagName("span");
for (var index = 0; index < sps.length; index++)
{
var sp = sps[index];
if (sp.className == "label")
{
var s = sp.style.width.substring(0, sp.style.width.indexOf("px"));
var i = (s - sp.offsetWidth) / 2;
if (sp.style.textAlign == "center")
{
sp.style.paddingLeft = i;
sp.style.paddingRight = i;
}
else if (sp.style.textAlign == "right")
sp.style.paddingLeft = i * 2;
else
sp.style.paddingRight = i * 2;
}
}
</script>
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition
"Joerg Jooss" <ne********@joergjooss.de> wrote in message
news:xn****************@msnews.microsoft.com...
Chris Botha wrote:
I am porting an existing 2003 project to 2005. Yesterday I found that
some of my Java script did not want to work. After eventually
examining the HTML view of the new and old form for differences, I
noticed the DOCTYPE lines pretty close to the top of the forms in
HTML view differ. I removed the line in the new form and my Java
script worked. Today I noticed that a SPAN on a new form with the
width property set to 100% displayed about 1/4 over the page, so I
thought let me give the DOCTYPE line a shot, I removed it and the
SPAN displays perfectly. So, I am not sure if the DOCTYPE line
generated by VS2005 is evil or a new standard, but it surely causes
problems.
What you experience is called "quirks" mode. See
http://www.quirksmode.org/css/quirksmode.html for more details.
Here's how IE 6 decides between quirks and standards compliant mode:
http://msdn.microsoft.com/library/de.../en-us/dnie60/
html/cssenhancements.asp
Unfortunately, Visual Studio .NET 2002 and 2003 both use a default
DOCTYPE in ASP.NET that *enables* quirks mode.
[Hony soit qui mal y pense ;-)]
What does all that mean for your HTML? If it requires quirks mode, it's
most likely broken...
Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de