Opening a stream in Word with JS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • icewalker@hotpop.com

    Opening a stream in Word with JS

    Hi

    I have been trying to open a new window in Word/OO Writer with JS
    using the following code (and numerous variations I could add...):
    tw = window.open('ab out:blank','');
    tw.document.wri teln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN">');
    tw.document.wri teln('<HTML><HE AD>');
    tw.document.wri teln('Content-type: application/msword');
    tw.document.wri teln('</HEAD>');
    tw.document.wri teln('<BODY><FO RM method="POST">' );
    tw.document.wri teln('Hello earth');
    tw.document.wri teln('</FORM></BODY></HTML>');

    The new window opens OK, but in the browser. What am I missing? Thank
    you in advance.
  • Thomas 'PointedEars' Lahn

    #2
    Re: Opening a stream in Word with JS

    icewalker@hotpo p.com wrote:
    I have been trying to open a new window in Word/OO Writer with JS
    using the following code (and numerous variations I could add...):
    tw = window.open('ab out:blank','');
    tw.document.wri teln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN">');
    tw.document.wri teln('<HTML><HE AD>');
    tw.document.wri teln('Content-type: application/msword');
    tw.document.wri teln('</HEAD>');
    tw.document.wri teln('<BODY><FO RM method="POST">' );
    tw.document.wri teln('Hello earth');
    tw.document.wri teln('</FORM></BODY></HTML>');
    I would presume that is atrocious by any standard of any sentient species.
    Consider this instead:

    var tw = window.open('', 'popup');
    if (tw)
    {
    var d;
    if ((d = tw.document) && d.open && d.write && d.close)
    {
    d.open("text/html");
    d.write(
    '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"'
    + ' "http://www.w3.org/TR/html4/loose.dtd">'
    + '<HTML>'
    + '<BODY><FORM action="" method="POST">'
    + 'Hello Earth'
    + '<\/FORM><\/BODY><\/HTML>');
    d.close();
    }
    }
    The new window opens OK, but in the browser. What am I missing? [...]
    Isn't it obvious to you that a word processor is not a browser, that HTML is
    not HTTP, and that neither HTML or OO Writer are MS Word? And your
    generated markup is far from being Valid.

    In short: You don't have a single clue what you are doing.


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann

    Comment

    • David Mark

      #3
      Re: Opening a stream in Word with JS

      On Oct 30, 9:20 am, icewal...@hotpo p.com wrote:
      Hi
      >
      I have been trying to open a new window in Word/OO Writer with JS
      using the following code (and numerous variations I could add...):
      tw = window.open('ab out:blank','');
      tw.document.wri teln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
      Transitional//EN">');
      Why transitional? Looks like a brand new document.
      tw.document.wri teln('<HTML><HE AD>');
      tw.document.wri teln('Content-type: application/msword');
      What is this supposed to do?

      [snip]

      What are you trying to do exactly? If you want a new Word window,
      launch a blank document (or template) with a type that is associated
      with Word (e.g. DOC, DOT.) Use the open method of the window object.

      Comment

      Working...