470,834 Members | 1,629 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,834 developers. It's quick & easy.

Popping up text in a window

Hello,
Just wanted to check if this was possible. I have n blocks of text
and I would like each to pop up in a window. Hoever, I don't want to
create n different HTML pages and invoke each one through window.open.
Is there some way I can call window.open and pass the text to it and
have that text appear in the popup window? Styling is not important.
I don't care if the text just appears in plain font.

Thanks -
Jul 20 '05 #1
2 1835
D. Alvarado wrote:
Hello,
Just wanted to check if this was possible. I have n blocks of text
and I would like each to pop up in a window. Hoever, I don't want to
create n different HTML pages and invoke each one through window.open.
Is there some way I can call window.open and pass the text to it and
have that text appear in the popup window? Styling is not important.
I don't care if the text just appears in plain font.

Thanks -


How about this approach? If you like this, you can make the window any
size, with or without scroll bars, and you can make it appear centered.
Once you get started post your code and you can get specific help for
any features you want to work on.

Mike
<html>
<title>CodeAve.com(JavaScript New Window within Previous Page)</title>
<body bgcolor="#FFFFFF">
<script language="JavaScript">
<!--
function open_new_window() {
new_window = open("","displayWindow","width=575,height=290,left =10,top=10");

// open new document
new_window.document.open();

// Text of the new document goes here
// Replace your " with ' or \" or your document.write statements will fail

new_window.document.write("<html>");
new_window.document.write("<head>");
new_window.document.write("<meta http-equiv='Content-Type'
content='text/html; charset=windows-1252'>");
new_window.document.write("<title>Table of Data</title>");
new_window.document.write("<style type='text/css'>");
new_window.document.write(" td { text-align: right; }");
new_window.document.write(" td.1 { text-align: left; }");
new_window.document.write("</style>");
new_window.document.write("</head>");
new_window.document.write("<body>");
new_window.document.write("<table border='1' cellspacing='1' width='555'
height='246' style='border-collapse: collapse'>");
new_window.document.write(" <tr>");
new_window.document.write(" <td class = '1' width='111'>Sonnenstand
in Grad über dem Horizont ein<br>Elevation of the sun (degrees above the
horizon</td>");
new_window.document.write(" <td class = '1' width='111'>Optimaler
Anstellwinkel des Spiegels °A<br>Optimal mirror orientation °A</td>");
new_window.document.write(" <td class = '1'
width='111'>Energieerzeugung Watts<br>Power output Watts</td>");
new_window.document.write(" <td class = '1' width='111'>Mit der
erzeugten Energie können Sie Grams<br>With the above displayed energy
you can heat Grams</td>");
new_window.document.write(" <td class = '1' width='111'>converted to
lbs:</td>");
new_window.document.write(" </tr>");
new_window.document.write(" <tr>");
new_window.document.write(" <td>0°</td>");
new_window.document.write(" <td>60°</td>");
new_window.document.write(" <td>138,56 W</td>");
new_window.document.write(" <td>552 g</td>");
new_window.document.write(" <td>1 lb 3.5 ozs</td>");
new_window.document.write(" </tr>");
new_window.document.write("</table>");
new_window.document.write("</body>");
new_window.document.write("</html>");

// close the document
new_window.document.close();
}
// -->
</script><a onclick="open_new_window()"
style="cursor:pointer;cursor:hand;" ><font color="#008080"><u>Open New
Window</u></font></a>

</body>
</html>

Jul 20 '05 #2
On Sat, 14 Feb 2004 19:08:05 -0800, mscir <ms***@access4less.net> wrote:
<html>
<title>CodeAve.com(JavaScript New Window within Previous Page)</title>
<body bgcolor="#FFFFFF">
Why don't you add this to the CSS rules below?

body {
background-color: #ffffff;
}
<script language="JavaScript">
Missing the required type attribute. Change to:

<script type="text/javascript">
<!--
Don't use SGML comments in script blocks
function open_new_window() {
new_window =
open("","displayWindow","width=575,height=290,left =10,top=10");

// open new document
new_window.document.open();

// Text of the new document goes here
// Replace your " with ' or \" or your document.write statements will //
fail
Or use single quotes for the document.write statements and escape
apostrophes.
new_window.document.write("<html>");
No DOCTYPE? Tsk, tsk.

[snip]
</script><a onclick="open_new_window()"
style="cursor:pointer;cursor:hand;" >
You do realise that the first rule (cursor: pointer) in the style
attribute above is totally useless, don't you?
<font color="#008080"><u>Open New Window</u></font></a>
Again, why not use a CSS rule instead of deprecated elements?

a {
color: #008080;
cursor: hand;
text-decoration: underline;
}
</body>
</html>


Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John | last post: by
17 posts views Thread by Paul Rubin | last post: by
3 posts views Thread by Lee David | last post: by
4 posts views Thread by VB Programmer | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.