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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to close a popup window and print data displayed in it.

Status
Not open for further replies.

adhp55555

Programmer
Oct 24, 2003
9
US
Hi everyone,
From a main screen, when users click an anchor, a popup window named ExtraWin is invoked and displays some data. I want to create 2 commands: "Close Window" and "Print Doc" in that popup window so that when users click "Close Window", the window will close, and when users click "Print Doc" the data in popup window is printed.
Questions:
1) How do I continue to code to display these two commands in the popup window?
2) How do I code to close the popup window?
3) How do I code to print the data displayed in the popup window?

My PopupWindow function is as follows:

function PopUpWindow(ddnnum,FromCol,ToCol,FieldSize,FieldFormat,BookName)
{
ExtraWin = window.open("", "_blank", config='width=600,height=600,left=200,top=150');
ExtraWin.document.write(&quot;<H1> Field Information </H1>&quot;);
ExtraWin.document.write(&quot;<b>&quot; + &quot;DDN Number : &quot; + &quot;</b>&quot; + ddnnum + &quot;<br></br>&quot;);
ExtraWin.document.write(&quot;<b>&quot; + &quot;From Col : &quot; + &quot;</b>&quot; + FromCol + &quot;<br></br>&quot;);
ExtraWin.document.write(&quot;<b>&quot; + &quot;To Col : &quot; + &quot;</b>&quot; + ToCol + &quot;<br></br>&quot;);
ExtraWin.document.write(&quot;<b>&quot; + &quot;Field Size: &quot; + &quot;</b>&quot; + FieldSize + &quot;<br></br>&quot;);
ExtraWin.document.write(&quot;<b>&quot; + &quot;Field Format: &quot; + &quot;</b>&quot; + FieldFormat + &quot;<br></br>&quot;);
ExtraWin.document.write(&quot;<b>&quot; + &quot;Book Name: &quot; + &quot;</b>&quot; + BookName + &quot;<br></br>&quot;);
}

Thank you for your help.

adhp55555
 
ExtraWin.document.write(&quot;<p><a href=&quot;#&quot; onclick=&quot;window.close;&quot;>Close</a></p>&quot;);

ExtraWin.document.write(&quot;<p><a href=&quot;#&quot; onclick=&quot;window.print();&quot;>Print</a><p/>&quot;);

Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
Thank you Tracey,
&quot;Close&quot; worked for me, but I still have problem with &quot;Print&quot;. I did code the &quot;close&quot; as follows:
ExtraWin.document.write('<a href=&quot;javascript:window.close()&quot;>Close</a>');
and it worked. My problem was that I used &quot;Window.close()&quot; instead of &quot;window.close()&quot;. The letter &quot;W&quot; was in capital instead of lower case.

I coded the &quot;print&quot; as follows:
ExtraWin.document.write('<a href=&quot;javascript:window.print()&quot;>Print</a>');
and even added &quot;return false&quot; as follows:
ExtraWin.document.write('<a href=&quot;javascript:window.print();return false&quot;>Print</a>');

it still didn't work. When I clicked it, nothing happened. My browser is IE6, and the popup window is called from XSLT. Do you get any idea ? why doesn't &quot;Print&quot; work? Thanks

adhp55555
 
ah yes, dont you hate case sensitivity?
Unfortunately Im a delphi programmer and not javascript, which is why i hang around here.
I copied <a href=&quot;javascript:window.print();&quot;>Print</a>
into my test page and it worked fine so Im at the end of my advice (it even worked without the ;) using IE6.

Providing the source HTML of your popup has that code (then you can rule out xslt or asp), it should envoke your print dialog.

just a thought.. you dont have a pupup blocker enabled?


Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top