W3C home > Mailing lists > Public > www-html@w3.org > July 2006

Re: xhtml 2.0 noscript

From: Simon Pieters <zcorpan@hotmail.com>
Date: Tue, 25 Jul 2006 14:27:34 +0000
Message-ID: <BAY109-F26E4C7AB406D0C26A7B6FFB45A0@phx.gbl>
To: lholst@students.cs.uu.nl
Cc: www-html@w3.org

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:16:07 GMT