Sometimes we require to show the print dialog on as soon as we load the Web Page, the following piece of script can achieve the same, simply paste the script block on the page and you will see the Windows print dialog when you load the webPage.
<script type="text/javascript">
function PrintWindow()
{
window.print();
CheckWindowState();
}
function CheckWindowState()
{
if(document.readyState=="complete")
{
window.close();
}
else
{
setTimeout("CheckWindowState()", 2000)
}
}
PrintWindow();
</script>
--------------------------------------------------------------------------------------------------------------------------------------
The readyState property indicates the current state of the XML document.
This property is read-only and returns one of the following values indicating the instantiation and download state of the XML document.
- LOADING
loading in progress; reading persisted properties but not yet started parsing data. For purposes of the standard readyState definitions, data should be considered equivalent to BLOB properties.
- LOADED
reading of persisted properties completed; reading and parsing data, but the object model is not yet available.
- INTERACTIVE
some data has been read and parsed, and the object model is available on the partially received data set. The object model at this stage is read-only.
- COMPLETED
the document has been completely loaded, successfully or unsuccessfully.
This property is a Microsoft extension to the W3C DOM.