Re: xhtml 2.0 noscript

Hi,

From: Laurens Holst <lholst@students.cs.uu.nl>
><?xml version="1.0" encoding="UTF-8"?>
><!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="en" xml:lang="en">
><head>
>   <title>No script alternative</title>
>   <style type="text/css">
>     .noscript .noscript {display: none}
>   </style>
>   <script type="text/javascript">
>     function go() {
>         if (document.XMLHttpRequest) {
>            document.documentElement.className = 'noscript';
>            
>document.body.appendChild(document.createElement('p').appendChild(document.createTextNode('This 
>document has script')));
>        }
>         return true;
>     }
>   </script>
></head>
><body onload='go();'>
>   <h1>A noscript alternative</h1>
>   <p class="noscript">This document has no script</p>
></body>
></html>
>
>Then.

This example still relies on CSS (consider JS on and CSS off). This would be 
a better approach:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <title>No script alternative</title>
  <script type="text/javascript">
   function go() {
     document.getElementsByTagName('p')[0].firstChild.data = 'This document 
has script';
     return true;
   }
   window.addEventListener('load', go, false);
  </script>
</head>
<body>
  <h1>A noscript alternative</h1>
  <p>This document has no script</p>
</body>
</html>

<noscript> doesn't really work in XML anyway. At least not in the same way 
as it works in HTML, because it is parsed as CDATA in HTML when scripting is 
enabled.

Regards,
Simon Pieters

Received on Tuesday, 25 July 2006 14:27:53 UTC