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


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">
>   <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 has script')));
>        }
>         return true;
>     }
>   </script>
><body onload='go();'>
>   <h1>A noscript alternative</h1>
>   <p class="noscript">This document has no script</p>

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">
  <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);
  <h1>A noscript alternative</h1>
  <p>This document has no script</p>

<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 

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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:06:13 UTC