SheinTao
01-27-2006, 05:54 PM
Hello. I've written a Fax Cover Sheet generator web page for the company I work for. The user inputs all the information into a form and clicks 'print'. I do not know CGI, so i've accomplished the tasking using javascript to generate a pop-up window containing the formatted information from the form. However, no matter what I try, I can't get the browser to print the pop-up box instead of the main window. Can someone help me?
Here is sample code that imitates how the real page works:
**********************************************
<html>
<head>
<title>Print Test</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function displayHTML(form) {
var notes = form.notes.value;
var print = window.print();
win = window.open(", ", 'popup', 'toolbar = no, status = no');
win.document.write("<h1>" + notes + "</h1>");
win.document.write("<SCRIPT LANGUAGE='JavaScript'>" + print + ";</script>");
}
// End -->
</script>
</head>
<body>
<form>
<textarea cols=50 rows=10 name="notes"></textarea><br>
<input type="button" value=" Print " onclick="displayHTML(this.form)">
</form>
</body>
</html>
********************************************
I would like the browser to print the resulting pop-up instead of the page where the user types in the information.
Can anyone tell me how to accomplish this?
Thanks in advance,
-Shein
Here is sample code that imitates how the real page works:
**********************************************
<html>
<head>
<title>Print Test</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function displayHTML(form) {
var notes = form.notes.value;
var print = window.print();
win = window.open(", ", 'popup', 'toolbar = no, status = no');
win.document.write("<h1>" + notes + "</h1>");
win.document.write("<SCRIPT LANGUAGE='JavaScript'>" + print + ";</script>");
}
// End -->
</script>
</head>
<body>
<form>
<textarea cols=50 rows=10 name="notes"></textarea><br>
<input type="button" value=" Print " onclick="displayHTML(this.form)">
</form>
</body>
</html>
********************************************
I would like the browser to print the resulting pop-up instead of the page where the user types in the information.
Can anyone tell me how to accomplish this?
Thanks in advance,
-Shein