robert_gsfame Posted February 11, 2010 Share Posted February 11, 2010 I have this function function printContent(id){ str=document.getElementById(id).innerHTML newwin=window.open('','printwin','left=100,top=0,width=810,height=800,scrollbars=yes'); newwin.document.write('<HTML>\n<HEAD>\n'); newwin.document.write('<TITLE>Print Page</TITLE>\n'); newwin.document.write('<link rel="stylesheet"/>'); newwin.document.write('<style type="text/css">'); newwin.document.write('</style>'); newwin.document.write('<script>\n') newwin.document.write('function chkstate(){\n') newwin.document.write('if(document.readyState=="complete"){\n') newwin.document.write('window.close()\n') newwin.document.write('}\n') newwin.document.write('else{\n') newwin.document.write('setTimeout("chkstate()",2000)\n') newwin.document.write('}\n') newwin.document.write('}\n') newwin.document.write('function print_win(){\n') newwin.document.write('window.print();\n') newwin.document.write('chkstate();\n') newwin.document.write('}\n') newwin.document.write('<\/script>\n') newwin.document.write('</HEAD>\n') newwin.document.write('<BODY onload="print_win()">\n') newwin.document.write(str) newwin.document.write('</BODY>\n') newwin.document.write('</HTML>\n') newwin.document.close() } I only have a little problem with window.open(), i dont want to open a new window thx Link to comment https://forums.phpfreaks.com/topic/191773-javascript-small-problem/ Share on other sites More sharing options...
RussellReal Posted February 11, 2010 Share Posted February 11, 2010 uhm.. you kinda deserve a bonk on the head lol. window.open opens a new window.. if you don't want to open a new window.. don't call window.open Link to comment https://forums.phpfreaks.com/topic/191773-javascript-small-problem/#findComment-1010937 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.