Opening a stream in Word with JS

I

icewalker

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('about:blank','');
tw.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">');
tw.document.writeln('<HTML><HEAD>');
tw.document.writeln('Content-type: application/msword');
tw.document.writeln('</HEAD>');
tw.document.writeln('<BODY><FORM method="POST">');
tw.document.writeln('Hello earth');
tw.document.writeln('</FORM></BODY></HTML>');

The new window opens OK, but in the browser. What am I missing? Thank
you in advance.
 
T

Thomas 'PointedEars' Lahn

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('about:blank','');
tw.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">');
tw.document.writeln('<HTML><HEAD>');
tw.document.writeln('Content-type: application/msword');
tw.document.writeln('</HEAD>');
tw.document.writeln('<BODY><FORM method="POST">');
tw.document.writeln('Hello earth');
tw.document.writeln('</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
 
D

David Mark

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('about:blank','');
tw.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">');

Why transitional? Looks like a brand new document.
tw.document.writeln('<HTML><HEAD>');
tw.document.writeln('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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,279
Latest member
LaRoseDermaBottle

Latest Threads

Top