View Full Version : Generating Pop-up Window
01-19-2006, 03:45 AM
First off, as usual, I would like to thank all you kind folks that have helped me in the past. My most recent project (Stellar Body Position Calculator) has turned into a "Stellar" success. :p Now, however, I am looking to add some new features.
One of the features I would like to add is to allow the user to generate results for several Stellar Bodies. This, in and of itself, is not going to be a huge problem. What is going to be a problem, however, is displaying those results. My thought is to provide a "calculate" button that not only generates the results, but also stores them in an array. Again, not too much of a problem. What I would like to do with that array is render it in Table Format in a pop-up window so that the user can either print or save it in some fashion.
What I have accomplished so far is;
-Generating the array of values
-Opening the pop-up window
01-19-2006, 05:26 AM
from the new window.
01-19-2006, 01:39 PM
01-23-2006, 11:55 AM
var w = window.open("", "popup", "width=600, height=400, resizable=1"); //create a blank window
//generate html tags
var html = '<html><head><title>Popup</title></head><body>\n';
html += '<table>';
//loop through the array to store the content in "html" variable
html += '</table></body></html>';
w.document.write(html); //output html tags to popup window
w.document.close(); //close the output stream
w.focus(); //set focus to the popup window
01-23-2006, 05:19 PM
Once again I find myself thanking you Glenn. I did manage to find a tutorial on the subject, but it wasn't very clear. Coupled with your code, however, it now makes sense.
01-23-2006, 09:29 PM
Actually, anyone can answer, but I figured I would direct this towards Glenn first since he was the one that supplied the coding base for what I am trying to accomplish.
The scripting you laid out looks at though it will work just fine for what I am trying to accomplish, however, I was wondering if . .
1: I can add a doctype to the html variable
From what I can see, I don't think it would cause a problem if I added these things in (mostly the doctype and CSS) but if there is a problem with adding those things, I figured I better ask before I pull my hair out wondering why it isn't working. :D
Basicly I am thinking it would look something like this, but just want to be sure. . .
function displaydata() //opens new window and displays stored data in table format
var showdata=window.open("","popup","width=700 height=500, toolbar, scrollbars, menu, resizable")
var data='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"\n'
data+='<title>Accumulated Data Results</title>'
And so on and so forth until I have filled the table using the loop you suggested and then closed out with the last </html> tag and what not. Now I realize that what I have above could all have been smushed together, but I did it this way for ease of readability and what not. Anyways, if there is a problem adding this stuff, is their any sort of work around or am I just going to have to set my fonts and what not in a long-hand form?
01-24-2006, 01:19 AM