Opening a new html window using javascript

  • Thread starter Michael Landberg
  • Start date
M

Michael Landberg

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,top=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
 
G

GArlington

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,top=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...
 
M

Michael Landberg

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?
 
G

GArlington

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...
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top