Print page shows unchanged checkbox in IE with DocType
Strange problem. I have a simple webform where users can fill in text and check/uncheck some checkboxes. When this is printed to pdf or paper (or print preview) in IE (7 or 8) the checkboxes are printed unchanged. E.g. user sets a check, this is printed unchecked ... or with a pre-checked box with the user unchecked, is printed checked.
Same goes for the radio.
Onl开发者_如何学Cy when I remove the DocType completely, IE prints it correctly. But I need to use XHTML-strict.
This is a simple example which fails in IE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="nl" xml:lang="nl-NL">
<body>
<input type='checkbox' name='y'/><br/>
<input type='radio' name='x'/><br/>
</body>
</html>
Doesn't work with any doctype I tested (loose or html4).
Anyone a idea how to solve this?
Many thanks, Michael
Turns out to be a IE8 bug: http://webbugtrack.blogspot.com/2009/04/bug-444-ie8-printing-issues-in.html
It's not having this problem with "Compatibility View" turned ON.
A solution is to add the following in the header:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
Which kinda breaks validation and gives a problem when IE9 comes up.
Other "nice" workaround with JavaScript works also:
<input type='checkbox' name='y' onclick='SetCheck(this)'/>
.....
function SetCheck(el)
{
if(el)
{
if(el.checked) el.setAttribute('checked','checked');
else el.removeAttribute("checked");
}
}
But when you cannot rely on javascript being turned on, you're screwed by Microsoft.
精彩评论