Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New Window won't print

Status
Not open for further replies.

earlie

Instructor
May 3, 1999
1
US
I have created a window using wondow.open();<br>
<br>
The new window won't print, instead the last closed document goes to the printer.<br>
<br>
Do I need to add a document.close statement somewhere or what?<br>
<br>
Thanks
 
Are you trying to cause this new window to print using JavaScript? If so, then I don't know what to tell you, but if you're trying to print the window in Netscape, make SURE you've clicked the mouse in the new window before trying to print it. That may be a simple answer to your problem.<br>
<br>
-Robherc
 
hi earlie,

you can put code on body tag
onLoad=&quot;window.print()&quot;;
after writing on the document of that window
close document using
thatwindow.document.close();
now you will get printout of the window you intended

bye have a nice printing

vikas soni
 
Help...
I made this script,, its a preview page but i can´t print the preview page ...
prev=window.open(&quot;&quot;,&quot;Preview Page&quot;)... why???
please test this html page for me... i can´t print what i want... haaaaaaaaaaaaaaaaaaaaaaaaaaa
Im going crazy whith this...

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<html>
<head>
<title>Formulario de Pedidos</title>
<Script Language=&quot;JavaScript&quot;>
<!--
file://Function for Form preview
function pegadados()
{
file://Var that keep the values of text fields
var RepRazao = document.pedido.RepRazao.value;
var CliNome = document.pedido.CliNome.value;
var CliRazao = document.pedido.CliRazao.value;
var CliEndereco = document.pedido.CliEndereco.value;
var CliCep = document.pedido.CliCep.value;
var CliBairro = document.pedido.CliBairro.value;
var CliCidade = document.pedido.CliCidade.value;
var CliEstado = document.pedido.CliEstado.value;
var CliFone = document.pedido.CliFone.value;
var CliCGC = document.pedido.CliCGC.value;
var CliIE = document.pedido.CliIE.value;

// Var that keeps a new window,,, (preview results)
var prev = window.open('','Preview');

file://Put some words at nem window(prev)

file://Title
prev.document.write(&quot;<html><head><title>Preview Dados</title></head><body bgcolor=white><br><center>&quot;);


file://Put the form values at the new window(prev)

file://Values
prev.document.write(&quot;<table width=100% border=0><tr><td colspan=4><font size=2>Representante <br>&quot;+RepRazao+&quot;</font></td><td> </td><td> </td></tr><tr><td colspan=4><font size=2>Cliente <br>&quot;+CliNome+&quot;</font> </td><td> </td><td> </td></tr><tr><td colspan=4><font size=2>Razao Social</font><br><font size=2>&quot;+CliRazao+&quot;</font></td><td> </td><td> </td></tr><tr><td colspan=4><font size=2>Endereço</font><br><font size=2>&quot;+CliEndereco+&quot;</font></td><td colspan=2><font size=2>CEP</font><br><font size=2>&quot;+CliCep+&quot;</font></td></tr><tr><td colspan=2><font size=2>Bairro</font><br><font size=2>&quot;+CliBairro+&quot;</font></td><td colspan=2><font size=2>Cidade</font><br><font size=2>&quot;+CliCidade+&quot;</font></td><td><font size=2>Estado</font><br><font size=2>&quot;+CliEstado+&quot;</font></td><td><font size=2>Fone<br>&quot;+CliFone+&quot;</font></td></tr><tr><td colspan=2><font size=2>CGC</font><br><font size=2>&quot;+CliCGC+&quot;</font></td><td> </td><td colspan=2><font size=2>Inscricao Estadual</font><br><font size=2>&quot;+CliIE+&quot;</font></td><td> </td></tr></table><br><br>&quot;);



file://Button that should print the curent window(prev) but... not print Grrrrrrrrrr
prev.document.write(&quot;<br><br><input type=button name=imprime value=imprime onClick=javascript:self.print();></form></center>&quot;);

}

</script>

</head>
<body>
<form name=&quot;pedido&quot;>
<table width=&quot;100%&quot; border=&quot;0&quot;>
<tr>
<td colspan=&quot;4&quot;><font size=&quot;2&quot;>Representante <br>
<input type=&quot;text&quot; name=&quot;RepRazao&quot; size=&quot;60&quot; maxlength=&quot;50&quot; value=&quot;Logan Fast Slash S/A&quot;>
</font></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan=&quot;4&quot;><font size=&quot;2&quot;>Cliente <br>
<input type=&quot;text&quot; name=&quot;CliNome&quot; value=&quot;Maria&quot;>
</font> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan=&quot;4&quot;><font size=&quot;2&quot;>Razao Social</font><br>
<input type=&quot;text&quot; name=&quot;CliRazao&quot; size=&quot;50&quot; value=&quot;Costuras Limpas Ltda&quot;>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan=&quot;4&quot;><font size=&quot;2&quot;>Endereço</font><br>
<input type=&quot;text&quot; name=&quot;CliEndereco&quot; size=&quot;50&quot; value=&quot;Rua Linha 8, 456&quot;>
</td>
<td colspan=&quot;2&quot;><font size=&quot;2&quot;>CEP</font><br>
<input type=&quot;text&quot; name=&quot;CliCep&quot; value=&quot;9450132&quot;>
</td>
</tr>
<tr>
<td colspan=&quot;2&quot;><font size=&quot;2&quot;>Bairro</font><br>
<input type=&quot;text&quot; name=&quot;CliBairro&quot; value=&quot;ELGIN&quot;>
</td>
<td colspan=&quot;2&quot;><font size=&quot;2&quot;>Cidade</font><br>
<input type=&quot;text&quot; name=&quot;CliCidade&quot; size=&quot;30&quot; value=&quot;Pomba Branca&quot;>
</td>
<td><font size=&quot;2&quot;>Estado</font><br>
<input type=&quot;text&quot; name=&quot;CliEstado&quot; size=&quot;5&quot; value=&quot;PB&quot;>
</td>
<td><font size=&quot;2&quot;>Fone<br>
<input type=&quot;text&quot; name=&quot;CliFone&quot; size=&quot;25&quot; value=&quot;455 6987&quot;>
</font></td>
</tr>
<tr>
<td colspan=&quot;2&quot;><font size=&quot;2&quot;>CGC</font><br>
<input type=&quot;text&quot; name=&quot;CliCGC&quot; size=&quot;25&quot; value=&quot;456789/0001 23&quot;>
</td>
<td> </td>
<td colspan=&quot;2&quot;><font size=&quot;2&quot;>Inscricao Estadual</font><br>
<input type=&quot;text&quot; name=&quot;CliIE&quot; size=&quot;25&quot; value=&quot;789456123&quot;>
</td>
<td> </td>
</tr>
</table>
<p> </p>
<table border=&quot;1&quot;>
<div align=&quot;center&quot;>
<input type=&quot;button&quot; name=&quot;Btn_Preview&quot; value=&quot;Ver Pedido&quot; onClick=pegadados()>
</div>
</table>
</form>
</body>
</html>


Please Help...

Thanks [sig][/sig]
 
askjdhakjdh,

Two things.

1. In order to print reliably using the .print method you must use document.open() and document.close() before and after the .writes...

Code:
var prev = window.open('','Preview');
prev.document.open();
prev.document.write(&quot;blah,blah,blah&quot;)
prev.document.close();

2. Close your hiding tag <!-- with --> (has nothing to do with printing but is simply proper form.

Hope this helps, [sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top