@tasairis
Thanks to your help, I have managed to find a solution to the problem. While trying to get the server to send the text/html version of my pages when receiving "forcetype_html=," I noticed that the validator was giving some strange URL's like <
http://validator.w3.org/check?uri=http: ... _Validator[/b]%2F1.606>. After doing some experimentation, I remeber that one of my php scripts (from
http://www.workingwith.me.uk/articles/s ... /mimetypes )was sending mimetypes based on browser names and types. It took some time, but here is the code that I finally ended up with:
Code: Select all
<?php
if (stristr($_SERVER["HTTP_USER_AGENT"],"Mozilla")) {
$mime = "application/xhtml+xml";
}
if (stristr($_SERVER["HTTP_USER_AGENT"],"IE")) {
$mime = "text/html";
}
# special check for the W3C_Validator
if (stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator")) {
$mime = "application/xhtml+xml";
}
?>
<p><a href="http://validator.w3.org/check?uri=<?php $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
echo $url; ?>&charset=(detect+automatically)&doctype=Inlineamp;&group=0&user-agent=Mozilla%2F1.606"><object width="88px" height="31px" type="image/png" data="http://www.w3.org/Icons/valid-xhtml11.png">Valid xhtml 1.1</object></a>
<a href="http://jigsaw.w3.org/css-validator/validator?uri=<?php $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
echo $url; ?>"><object width="88px" height="31px" type="image/png" data="http://www.w3.org/Icons/valid-css">Valid css</object></a>
</p>
I'll explain what I did in a bit more detail to help others who may benefit from this thread in the future. First, I gave instructions as to which browsers should receive which mimetype:
Code: Select all
<?php
if (stristr($_SERVER["HTTP_USER_AGENT"],"Mozilla")) {
$mime = "application/xhtml+xml";
}
if (stristr($_SERVER["HTTP_USER_AGENT"],"IE")) {
$mime = "text/html";
}
# special check for the W3C_Validator
if (stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator")) {
$mime = "application/xhtml+xml";
}
?>
Because Mozilla style browsers can usually (but not always) render pages as application/xhtml+xml, browsers claiming to be like Mozilla receive that mimetype. Internet Explorer type browsers on the other hand, receive the text/html version of the page.
Code: Select all
<p><a href="http://validator.w3.org/check?uri=<?php $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
echo $url; ?>&charset=(detect+automatically)&doctype=Inlineamp;&group=0&user-agent=Mozilla%2F1.606"><object width="88px" height="31px" type="image/png" data="http://www.w3.org/Icons/valid-xhtml11.png">Valid xhtml 1.1</object></a>
<a href="http://jigsaw.w3.org/css-validator/validator?uri=<?php $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
echo $url; ?>"><object width="88px" height="31px" type="image/png" data="http://www.w3.org/Icons/valid-css">Valid css</object></a>
</p>
This code tells the php script to have the validator check the Mozilla (application/xhtml+xml) version when viewing the page as xhtml 1.1. Using some of the "find and replace" functionality of php (like ob_start mentioned in
http://www.workingwith.me.uk/articles/s ... /mimetypes ) the "user-agent=Mozilla" to "user-agent=IE" which would check the text/html version of the page for validation errors. As for "user-agent=W3C_Validator" this would be for someone who goes directly to the validator and types (or pastes) the page's normal URL. In the case of my site, this would cause the validator to check the page as "XHTML 1.1 plus MathML 2.0 plus SVG 1.1" using the xhtml mime type. With a few additions, this code can be on any page from html 4.01 to xhtml 1.1 as well as future x/html doctypes thanks to use of the object element rather than the img element (
http://www.xml.com/pub/a/2003/07/02/dive.html ).
I realize that the code displayed in this post is incomplete and still not fully explained, but hopefully it will be helpful to anyone who would like allow their users to validate web pages, based on the mimetype being viewed by the visitor at the time.
@tasairis
Again, thank you for your help, without which I would not have been able to find a solution to this problem.