javascript - Auto close browser window -
javascript - Auto close browser window -
i want auto close window in firefox opened window.open() function. have searched stack overflow forum , found these links:
1) how close automatically webpage 2) automatically close current window , open new window new url address
but not much used javascript, not implement code appropriately.
please find below code opens window - needs auto closed. inserting in resulting html file makes invalid.
<script language="javascript" type="text/javascript"> function clickheretoprint(vpid,vage,vroom,vname,vsex,vdoc,vdat) { var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; disp_setting+="scrollbars=yes,width=300, height=200, left=100, top=25 resizable=yes"; //var content_vlue = document.getelementbyid("t_pid").value; var docprint=window.open("","",disp_setting); docprint.document.open(); docprint.document.write('<html>'); docprint.document.write('<body style="margin:0.01in 0.01in 0.01in 0.01in; width:3in;height:2in;position:absolute;" onload="self.print()">'); docprint.document.write('<table height="25%">'); docprint.document.write('<tr>'); docprint.document.write('<td style=" font-weight: bold;" align="left">regd : '+vpid+' date :'+vdat+'</td>'); docprint.document.write('</tr>'); docprint.document.write('<tr>'); docprint.document.write('<td style=" font-weight: bold;" align="left">name : '+initcap(vname)+'</td>'); docprint.document.write('</tr>'); docprint.document.write('<tr>'); docprint.document.write('<td colspan=2 align="left"; ><b>age :</b>'+vage+' <b>category :</b>'+vsex+'</td>'); docprint.document.write('</tr>'); docprint.document.write('<tr>'); docprint.document.write('<td colspan=2 style="font-weight: bold;" >'+vdoc+' room:'+vroom+'</td>'); docprint.document.write('</tr>'); docprint.document.write('</table>'); docprint.document.write('<table height="25%">'); docprint.document.write('<tr><td style="height:1in;width:100%;font-family:code 39;"> <center>'); docprint.document.write('<font face="code 39" size="7">'); docprint.document.write('*'+vpid+'*'); docprint.document.write('</font>'); docprint.document.write('</center></td></tr>'); docprint.document.write('</table>'); docprint.document.write('</body></html>'); docprint.document.close(); docprint.focus(); }
please allow me know how edit resulting file auto closes after 3 seconds.
thanks!
ps: little detailed reply appreciated quite new field.
codepen
try it:
<button onclick="openwin()">open , close after 3s</button> <script> var mywindow; function openwin() { mywindow = window.open("", "mywindow", "width=200, height=100"); mywindow.document.write("<p>this 'mywindow'</p>"); settimeout(closewin, 3000); } function closewin() { mywindow.close(); } </script>
javascript html
Comments
Post a Comment