By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 3,231 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

Opening a stream in Word with JS

P: n/a
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.
Oct 30 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ic*******@hotpop.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('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
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Nov 2 '08 #2

P: n/a
On Oct 30, 9:20*am, icewal...@hotpop.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('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.
Nov 3 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.