Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Opening a new html window using javascript

Reply
Thread Tools

Opening a new html window using javascript

 
 
Michael Landberg
Guest
Posts: n/a
 
      02-06-2008
Hi

I have a piece of code that has to open a new small window with some
formatting text in it. If I run the code and the new windows opens the
text is displayed without the formatting ( spaces, open lines between
some text, etc.). But when I place an alert function like
alert(newContent) I can see perfectly all the formatting that is in
the text.

Is there a variable I have to add in my code below to make sure that
the new window is opened with the text formatting?


newWindow =
window.open('','','width=500,height=300,left=550,t op=250",status=no,toolbar=no,scrollbars=yes ,
menubar=no');

// write HTML to new window document
newWindow.document.write(newContent)


Any help will be appreciated.

Regards
 
Reply With Quote
 
 
 
 
GArlington
Guest
Posts: n/a
 
      02-06-2008
On Feb 6, 8:28 am, Michael Landberg <(E-Mail Removed)> wrote:
> Hi
>
> I have a piece of code that has to open a new small window with some
> formatting text in it. If I run the code and the new windows opens the
> text is displayed without the formatting ( spaces, open lines between
> some text, etc.). But when I place an alert function like
> alert(newContent) I can see perfectly all the formatting that is in
> the text.
>
> Is there a variable I have to add in my code below to make sure that
> the new window is opened with the text formatting?
>
> newWindow =
> window.open('','','width=500,height=300,left=550,t op=250",status=no,toolbar=no,scrollbars=yes ,
> menubar=no');
>
> // write HTML to new window document
> newWindow.document.write(newContent)
>
> Any help will be appreciated.
>
> Regards


Check the docs about how document.write() works and you will see the
error of your ways...
 
Reply With Quote
 
 
 
 
Michael Landberg
Guest
Posts: n/a
 
      02-06-2008
On 6 feb, 11:52, GArlington <(E-Mail Removed)> wrote:
> On Feb 6, 8:28 am, Michael Landberg <(E-Mail Removed)> wrote:
>
>
>
>
>
> > Hi

>
> > I have a piece of code that has to open a new small window with some
> > formatting text in it. If I run the code and the new windows opens the
> > text is displayed without the formatting ( spaces, open lines between
> > some text, etc.). But when I place an alert function like
> > alert(newContent) I can see perfectly all the formatting that is in
> > the text.

>
> > Is there a variable I have to add in my code below to make sure that
> > the new window is opened with the text formatting?

>
> > newWindow =
> > window.open('','','width=500,height=300,left=550,t op=250",status=no,toolbar*=no,scrollbars=yes ,
> > menubar=no');

>
> > // write HTML to new window document
> > newWindow.document.write(newContent)

>
> > Any help will be appreciated.

>
> > Regards

>
> Check the docs about how document.write() works and you will see the
> error of your ways...- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -


Hi

I don't understand what you mean. I have read online what this
function does and saw examples of it. But I cannot find out what I am
doing wrong. Which docs do you mean?
 
Reply With Quote
 
GArlington
Guest
Posts: n/a
 
      02-06-2008
On Feb 6, 11:30 am, Michael Landberg <(E-Mail Removed)> wrote:
> On 6 feb, 11:52, GArlington <(E-Mail Removed)> wrote:
>
>
>
> > On Feb 6, 8:28 am, Michael Landberg <(E-Mail Removed)> wrote:

>
> > > Hi

>
> > > I have a piece of code that has to open a new small window with some
> > > formatting text in it. If I run the code and the new windows opens the
> > > text is displayed without the formatting ( spaces, open lines between
> > > some text, etc.). But when I place an alert function like
> > > alert(newContent) I can see perfectly all the formatting that is in
> > > the text.

>
> > > Is there a variable I have to add in my code below to make sure that
> > > the new window is opened with the text formatting?

>
> > > newWindow =
> > > window.open('','','width=500,height=300,left=550,t op=250",status=no,toolbar*=no,scrollbars=yes ,
> > > menubar=no');

>
> > > // write HTML to new window document
> > > newWindow.document.write(newContent)

>
> > > Any help will be appreciated.

>
> > > Regards

>
> > Check the docs about how document.write() works and you will see the
> > error of your ways...- Tekst uit oorspronkelijk bericht niet weergeven -

>
> > - Tekst uit oorspronkelijk bericht weergeven -

>
> Hi
>
> I don't understand what you mean. I have read online what this
> function does and saw examples of it. But I cannot find out what I am
> doing wrong. Which docs do you mean?


document.write() OVERWRITES your complete document...
So, you have to put ALL <html> <body> ... </body> </html> in your
string in order for the document to be formatted as html, otherwise it
is plain text...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a new browser window to a specific size without the menu bar and address window. UJ ASP .Net 2 06-27-2005 08:21 PM
opening new window in one window using Tkinter -- Help please Clara Python 6 04-25-2005 03:09 AM
Opening a new page (i.e., spawning new IE window) via JavaScript kills the Session variable? POL8985 ASP .Net 1 01-31-2005 04:05 PM
Closing child window when opening a new Window Patrick Olurotimi Ige ASP .Net 2 12-14-2004 04:59 AM
Opening a new window using Javascript James Bondin Javascript 2 05-19-2004 02:25 PM



Advertisments