Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29090

Re: document.open

From Joao Rodrigues <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: document.open
Date 2016-01-01 13:24 -0200
Organization Aioe.org NNTP Server
Message-ID <n665o3$859$1@speranza.aioe.org> (permalink)
References <nodeName-20160101150007@ram.dialup.fu-berlin.de>

Show all headers | View raw


On 01/01/2016 12:18 PM, Stefan Ram wrote:
>    The MDN documentation for »document.open« shows it with no
>    arguments:
>
> document.open()

I think that was the old DOM Level 2 HTML Specification for the open() 
method of the HTMLDocument interface:
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-72161170>

>
>    . But some other web pages give optional arguments:
>
> document.open( MIMEtype, replace )

That is according to the HTML5 specification:

document = document.open( [ type [, replace ] ] )

For more details, see there:
<http://www.w3.org/TR/html5/webappapis.html#dom-document-open>


>
>    . But this does not seem to work with Mozilla Firefox 38.
>    OTOH, it does also not simply ignore the first argument.
>
>    Inserting the following code into the JavaScript console
>    of Mozilla Firefox 38 shows the page as intended. Note the
>    MIME type »text/html«:
>
> document.open( "text/html", "replace" );
> document.writeln
> ( '<!DOCTYPE HTML>'+
>    '<html lang="en">\r\n'+
>    '<head><meta charset="UTF-8"><title>Main</title><head><style type="text/css">\r\n'+
>    '</style></head></head><body>\r\n'+
>    '    <p>hello, world</p>\r\n'+
>    '<pre><code><script type="application/javascript;version=1.8">\r\n'+
>    '</script></code></pre></body></html>\r\n' );
> document.close();
>
>    . But when the MIME type is changed into »application/xhtml+xml«,
>    the document is not rendered as intended:
>
> document.open( "application/xhtml+xml", "replace" );
> document.writeln
> ( '<!DOCTYPE HTML>'+
>    '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">\r\n'+
>    '<head><meta charset="UTF-8"><title>Main</title><head><style type="text/css">\r\n'+
>    '</style></head></head><body>\r\n'+
>    '    <p>hello, world</p>\r\n'+
>    '<pre><code><script type="application/javascript;version=1.8">/*<![CDATA[*/\r\n'+
>    '/*]]>*/</script></code></pre></body></html>\r\n' );
> document.close();
>
>    . (This is intended to be a polyglot HTML5 document.)
>
>    Instead, it here shows the source code, which is the
>    argument of the »writeln« in the browser.
>

document = document . open( [ type [, replace ] ] )

"If the type argument is omitted or has the value "text/html", then the 
resulting Document has an HTML parser associated with it, which can be 
given data to parse using document.write(). Otherwise, all content 
passed to document.write() will be parsed as plain text".
<http://www.w3.org/TR/html5/webappapis.html#dom-document-open>

See the steps for the write() and writeln() methods too:
<http://www.w3.org/TR/html5/webappapis.html#dom-document-write>

-- 
Joao Rodrigues

Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread


Thread

Re: document.open Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2016-01-01 13:24 -0200

csiph-web