Re: DOM-scripting -- FF problem



David Mark wrote:
SAM wrote:
Le 5/2/09 8:12 AM, maya a écrit :
I'm working on validation for a form..
http://www.mayacove.com/dev/js/mail.html
As you are in XHTML begin by doing :

<script type="text/javascript">
// <![CDATA[

// ]]>
</script>

(inserting the special comments cdata)

The document is not *served* as XML

That is true. A document can not be "served as XML"; either it is an XML
document or of an XML-based document type (e.g. XHTML 1.0 Transitional), or
it is not. However, a markup document can be declared as of ("served as")
an XML-based *media* type (e.g. application/xhtml+xml) or not, which is
likely to trigger the user agent used for parsing the markup: XML-based
media types, if supported, SHOULD trigger an XML parser, while SGML-based
media types usually trigger a tag-soup parser, or (seldom) an SGML parser.

and the above syntax wouldn't make sense if it was.

If the document type was an XHTML document type, the above syntax prevented
the author from escaping the markup characters `<', `>' and `&' in the
script code which would be necessary in order to achieve a Valid document
because the content model of the XHTML `script' element is PCDATA (Parsed
Character DATA). (That would, of course, be independent of the declared
media type and of which user agent was eventually selected to render the
document.) The recommended alternatives are to refer to script resources
with the `src' attribute, or not to use XHTML. See the XHTML 1.0
Specification, Second Edition, section 4.8.

It won't do anything for documents served as HTML either.

The "either" aside, exactly that is the beauty of it. In HTML, the content
model of the SCRIPT element is CDATA (Character DATA) instead where,
consequently, markup characters are regarded literal characters without
attached meaning. The single-line comment syntax of `//', which does not
need to be escaped in PCDATA, prevents the script engine from regarding this
line as a non-comment, regardless of the actual content model as implemented
by the actual user agent.

It's the JS equivalent of an urban myth.

You are mistaken.

problem is in FF, messages inserted in error div disappear after they
show up... I've never seen this before..
try :
<form action="" onsubmit="return validate()">
or :
<form action="" onsubmit="return sendMail()">

In all cases onsubmit will have to return false

Unless the request fails immediately. Scripting may be disabled as
well, so you need an action.

The value of the `action' attribute of the `form' element may be the empty
string. In that case, it is supposed to be regarded by the user agent as a
"same-document" relative URI-reference. This can make sense for documents
that use client-side scripting to parse the query-part of the request URI,
or for documents that are generated by a server-side application. See the
HTML 4.01 Specification, section 17.3, and RFC 3986, section 4.4.


PointedEars
.



Relevant Pages

  • Re: XML Processing
    ... characters in xml to to literal value. ... I've seen examples using the HTMLgen module. ... But here's another script ...
    (comp.lang.python)
  • Re: prompt not working
    ... >> A) a) You are declaring an XHTML document type and serve it ... > code I infer from the above that XHTML must be the "default" document ... The document type must be explicitly declared, ... > The book that I am using says to use comment tags to enclose all script ...
    (comp.lang.javascript)
  • Re: WINDOWS MEDIA FILE EDITOR - HELP!!!
    ... before (You might want to look at programs like microsofts XML Notepad ... The actual file format can be defined by a DTD ... >but it is all our clients protocol supports) and with this, been encoding asf ... It doesn't recognize the same script file as I once used...get ...
    (microsoft.public.windowsmedia)
  • Re: WSH in VS.NET 2003?
    ... or will wsh xml include a ... Get the "TechNet Script Center Sample Scripts" ... Other|Useful Scripting Technologies|Saving Data in XML Format ... There is no schema for getting MS. ...
    (microsoft.public.scripting.wsh)
  • Re: Import XML from Command-Line into SQL
    ... Set objBL = CreateObject ... >I'd probably create a mapping schema and a VB Script ... that uses the SQL XML ...
    (microsoft.public.sqlserver.xml)