473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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('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
2 2797
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sivaraman.S | last post by:
Issue: When I am opening a word document or a template from an ASP.NET Web page (language used VB.NET Visual Studio Version 2003) using Word.ApplicationClass object (Reference Word 11.0 object...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
1
by: Jose Egea | last post by:
Hello: I would like to make an application to manage word and pdf documents, opening and saving them in a sql database. Is there any way to open a document sending to the winword application a...
1
by: Walter Levine | last post by:
I just worked through a VB.Net sample program that creates an rft document and then opens it in Word. The code that opens the document is: Dim sFileName As String sFileName = "Sample1.doc" ...
3
by: richi | last post by:
Hello, i'm hoping that somebody can point me in the right direction with my problem. I have been tasked with creating a simple browser based application that will allow the user to upload Word...
2
by: Simon | last post by:
I'm simplying trying to download and and open word documents that are stored in the database. I figured out how to uploaded the documents as Byte, but I can't figure out how to get them back out...
11
by: moony marouane | last post by:
Hi all I'm looking for code regarding opening (not saving) binary files (pdf, word, excel...) from hard disk with asp, the website is hosted in C:\ and the pdf files are in D:\. Does anyone...
1
by: gangs | last post by:
I need to know how can I open a file which is named using UTF-16 encoding in unicode. I am desperately trying to open the file using the wofstream typedef, but even it takes the parameter as const...
5
by: Nitin Mahajan | last post by:
Guys Is there a way in C# to create a word object directly from a memory stream without passing that to hard disk (file stream). I think it doesn't makes sense to create a file just to read it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.