Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

Writing JavaScript for XHTML

Couple of notes :

1) The php example for detecting if the client accepts xhtml+xml will result in a php error of the client doesn't send what it accepts.

if (isset($_SERVER['HTTP_ACCEPT')) {
if( strpos( $_SERVER['HTTP_ACCEPT'], "application/xhtml+xml" ) ) {
  header( "Content-type: application/xhtml+xml" );
  echo '<?xml version="1.0" ?>'."\n";
} else {
  header( "Content-type: text/html" );
} else {
  header( "Content-type: text/html" );
}

solves that.

2) If you use the above trick, then you can't use the CDATA trick because it seems to cause issues in non xhtml+xml.

3) The "DOM changed" section is almost entirely incorrect.  Should we just remove it?

Document Tags and Contributors

 Contributors to this page: Bzbarsky, FunkyRes
 Last updated by: Bzbarsky,