473,770 Members | 7,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Oct 30 '08 #1
2 2816
ic*******@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
Nov 2 '08 #2
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.
Nov 3 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4017
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 Library), I am getting the following error: could not open macro storage (System.Runtime.comExeception) I am not getting any errors while opening the same word document or a template from a windows application. (Language Used VB.NET)
3
5587
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 document in Word; 2. opens the document and runs the merge process for the new data. I have managed to write the code to perform step 1 ok, but I'm having trouble with step 2. It opens the word document fine but does not perform the mail merge of...
1
1775
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 stream of the document I have in the database? And to save, how can I get a stream of a word document to save it in a database? I've been searching for information about this kind of process but I haven´t found.
1
4373
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" Response.Write( "<META HTTP-EQUIV=""REFRESH"" Content=""0;URL=" & sFileName & """>") I cannot get this to work in C#, can anybody show me how to construct this
3
5934
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 documents to SQL Server and then retrieve them when needed. Storing the Word document seems to be no problem but where I am stuck is on retrieving them and then displaying the Word documents as through ASP.NET it will be on the server i think. ...
2
2388
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 properly. The following code is what I've tried (vb.NET)... It goes as far as asking me to Save/Open the file, but when I do, the contents of the documents is the webage that the download link was on! I'm fairly new to programming/web...
11
2082
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 have an idea about this?? Many thanks in advance. Moony.
1
1962
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 char*, I tried converting the filename from UTF16 to UTF8 encoding, wofstream does not seem to work with that. What I gather is that streams internally use fopen for opening up a file, I could not find any way for passing a file descriptor to the...
5
6868
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 again in to word object. If some one has some brilliant idea please share. In a nutshell this is what I'm currently doing ByteArray --File Stream --Word Object and this I want to do
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.