Forum Moderators: phranque

Message Too Old, No Replies

target="console" window

how to...

         

Stidd

3:22 pm on Jun 24, 2003 (gmt 0)

10+ Year Member



I am using a the following code with a form button that prints the page in question..... What it does when the button is hit is opens a new window and displays the printers set up on the users machine and you have to print again. Is there a way to just get it to print on the users default printer without opening a separate window and allowing the user to setup the page?

<script language="JavaScript">
var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial()
{
if (document.getElementById!= null)
{
var html = '<HTML>\n<HEAD>\n';

if (document.getElementsByTagName!= null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0)
html += headTags[0].innerHTML;
}

html += '\n</HE' + 'AD>\n<BODY>\n';

var printReadyElem = document.getElementById("printReady");

if (printReadyElem!= null)
{
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printReady section in the HTML");
return;
}

html += '\n</BO' + 'DY>\n</HT' + 'ML>';

var printWin = window.open("","printSpecial");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
if (gAutoPrint)
printWin.print();
}
else
{
alert("Sorry, the print ready feature is only available in modern browsers.");
}
}

</script>

BlobFisk

3:35 pm on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I read your post correctly, Stidd, you are asking whether it's possible to bypass the printer console window?

The quick answer is no! This is a feature inherited from and inherent to the operating system on the users machine and there is no way to bypass this using a client-side scripting language.

The longer answer is "sort of"! I believe that it is possible using ActiveX, but this leads you down a path of serious security issues.

HTH

Stidd

4:17 pm on Jun 24, 2003 (gmt 0)

10+ Year Member



BlobFisk
Thanks for the response.... :-)
Ok so it sounds like I have to leave the printer console but why does the button open new page that has the address about:blank with the same exact content as the console window only in a full size window before opening the printer console. Is there a way to can that second page from openening?