Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Javascript document.write question

Reply
Thread Tools

Javascript document.write question

 
 
Brett Baisley
Guest
Posts: n/a
 
      02-17-2004
Hello

I have a block of html code that I want to run by calling a javascript
function to print it. Its basically a table with menu items in it that is
the same for many pages, and instead of copying/pasting everytime I change
it, I figure this will be better, as I only change it once.

The problem is, document.write doesn't handle multiple lines very well, so I
was wondering what is the best way to do this? Maybe there is even a better
way then javascript calls.

Anything will be great! Thanks!

Brett


 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      02-24-2004
mscir wrote:

> [...] If you mean the data is not easy to read on the generated page,
> insert \n where you want a newline to begin. Post your code for more
> specific suggestions.
>
> http://www.devguru.com/Technologies/...haracters.html
>
> This code generates a new window with a table.
>
> <html>


DOCTYPE declaration?

> <title>CodeAve.com(JavaScript New Window within Previous Page)</title>
> <body bgcolor="#FFFFFF">


Text color?

> <script language="JavaScript">


"type" attribute?

> <!--
> function open_new_window() {
> new_window =
> open("","displayWindow","width=575,height=620,left =10,top=10\n");


Wrong. The options (third) argument of window.open() must not
contain newline. And _window._open() is recommended since there
is document.open(). The function should be defined within
the "head" element, not the "body" element, to be available always.

> // open new document
> new_window.document.open();
>
> // Text of the new document goes here
> // Replace your " with ' or \" or document.write statements will fail
>
> new_window.document.write("<html>\n");


See above.

> new_window.document.write("<head>\n");
> new_window.document.write("<meta http-equiv='Content-Type'
> content='text/html; charset=windows-1252'>\n");

^^^^^^^^^^^^
What about UAs that does not support this Windows character set?
ISO-8859-1 is better.

> new_window.document.write("<title>Table of Data</title>\n");

^^
Not only that this is and creates invalid HTML for the most part, a
smaller example would have sufficed. You have posted more than 200
lines of garbage!


PointedEars
 
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
Question about question mark in JavaScript Jimolo Javascript 2 01-20-2008 05:02 PM
Generated JavaScript vs. Manually Created JavaScript: Which one comes first? Nathan Sokalski ASP .Net 4 11-08-2007 07:24 AM
JavaScript or not JavaScript Mark Rae ASP .Net 36 09-09-2006 01:12 PM
href="javascript:func()" vs href="#" onclick="javascript:func()" CRON HTML 24 06-20-2006 08:05 PM
Javascript -> Applet: variable reset after method call from javascript?! mcdeveloper Java 1 06-13-2006 08:34 AM



Advertisments