Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

disabling controls on page removes CSS

Status
Not open for further replies.

hugobossv8

Programmer
Jan 2, 2004
11
0
0
US
Hello,

I'm using the following code to disable all controls on my page - in IE 6.0, however, the CSS that's applied to my hyperlinks disappears. Is there anyway to retain the CSS settings on disabled controls?

for (i in document.all){

document.all.disabled = true;

}


Here's what my CSS looks like (notice the font size is set to 18px, but when the disabled script runs above, it appears to reduce the font size to 12px or some default size that IE uses):
<style type="text/css">
<!--
a:link {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
}
a:visited {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
}
a:active {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
}
a:hover {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
}

-->
</style>
 

You could try specifically adding a classname to the A elements... Not sure if it will fix the issue or not, however:

Code:
<style type="text/css">
a.bar, a.bar:link, a.bar:visited, a.bar:active, a.bar:hover {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
}
</style>

<a href="foo" class="bar">...</a>

Hope this helps,
Dan

 
Thanks, BillyRayPreachersSon, I tried what you recommended, but it didn't work...any other ideas?
 
Are you using a valid doctype?

--Chessbot

"Violence is the last refuge of the incompetent." -- Asimov, Foundation
 
Yes, I've tried XHTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="
And, I've tried HTML 4.01:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
Both Doctypes produce the same result. When the hyperlink is disabled with the code above the CSS disappears. The only time the CSS stays in place is if I disable the link directly in it's property like so:

<a href="" disabled="true">sample link </a>

But this is not an option for me, I need to diable all controls on the form at the same time using something like this:

for (i in document.all){

document.all.disabled = true;

}

If anyone can figure this out, I'd be very grateful!

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top