- From: Lachlan Hunt <lhunt07@postoffice.csu.edu.au>
- Date: Wed, 19 Nov 2003 17:55:35 +1100
- To: ernestcline@mindspring.com
- Cc: W3C HTML List <www-html@w3.org>
Ernest Cline wrote: >...I think we need to redefine how the script element is defined for XHTML2. >...It needs a different attribute than type to indicate the MIME type of the contents for the element. ><script datatype="text/javascript" type="image/gif" src="flashing_logo"> > // And here goes a script that if the UA doesn't support animated GIFs > // would try to replicated the effect via scripting. ></script> > A datatype generally refers to what type a variable, or function is (eg. String, int, etc...) in programming, not what language is being used. We could bring back that old language attribute that was, strangely, both introduced and deprecated in HTML 4. Of course, it would have to be completely redefined from its use in HTML 4 to something like this: 1. @language must contain %ContentType. 2. The type specified by @type applies only to the external resource. If the external resource can be used, then @language and the contents of the script are ignored. i.e. Exactly how it's defined in the embedding collection. 3. The type specifed by @language applies only to the contents of the <script> element. 4. If the UA does not recognise the type specified by @language as a *known scripting language*, then the UA (must/should)? render the contents of the <noscript> element. If <noscript> is not specifed, then the <script> just ignored. eg. if an author writes: <script language="text/unknown-script"> alert("This is JavaScript"); <noscript><p>Some useful content here</p></noscript> </script> Then, a UA should render the contents of the <noscript> element. However, this raises the question of how strict the @language should be. If the browser actually recognises the script above as javascript then should the browser still run the script, even though the language was specified wrongly? Perhaps it should be similar to @type: If the UA has been advised of a script type that it does not understand, then it should not bother attempting to execute the script, and always use the fallback mechanism. Another question this raises is, if @language is NOT specified, but @type is, and there is no external resource, but there is internal content (ie. just like current HTML4 to XHTML 1.1 scripts), should the @type be substited for the @language? eg. <script type="text/javascript"> // some javascript </script> >It has some other advantages besides allowing generic embedding. >Since type is not a required attribute in general, but needs to be >for script (and for style as well) so using a separate attribute seems >preferable, especially if type allows for multiple types to be indicated. > Agreed! While looking at the script and noscript elements, I noticed some other problems with them. The current draft (2003-05-06) states that: "When this module is used, the script and noscript elements are added to the Block and Inline content sets of the Block and Inline Text Modules..." Also, the content model for noscript is: (Heading | List | Block)+ Since <noscript> is added to the Inline content model, then it makes the following valid: <span>some text <script language="text/javascript">document.write("something");<noscript><h>Heading</h></noscript> more text</span> Is there a way to specify that when script and noscript are used within Inline elements, the content model is only (Inline)+, but when used within Block elements, the content model is (Heading | List | Block)+ using Schemas? I know it can't be done with DTDs. CYA ...Lachy
Received on Wednesday, 19 November 2003 01:55:34 UTC