print a page

R

rom

I need to print a html table when the user clicks on a
key. the problem is that i don't want the printer dialog
box to appear. i guess this is impossible in javascript so
i think to create an event that will be fired by a keyup
event, this event will submit the page, and i will be able
to print in from the vb.net without the printing dialog
box. the problem is that on the server i can't print the
web table because i already submitted that page.....well,
what i'm saying here is that i need help because i don't
know where to begin...i only know 1 thing - i need to
print the table after the user hits a key and the
operation must be very quick.

Thanks.
 
J

John Timney \(ASP.NET MVP\)

You cant print without that dialogue - its a security thing. How would you
like to visit spam.com and suddleny have a million pages printing at your
printer without you requesting them - which is in effect what you are trying
to do.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
W

weichung[MCSD,MCDBA]

Yes, I knew this is the limitation of Javascript.

However, from the MCP website, in the page to print the transcript, there is
an ActiveX button to print the transcript automatically without prompting
the print dialog box, do you have any idea on how do they achieve this?

Regards
Weichung
 
G

Guest

I'm running into the same issue. We're using IE in kiosk mode with a touch
screen interface on a dedicated machine for an internal application.
Bypassing this dialouge is necessary to keep the "users" out of the print
settings ect... :)

If it were my choice, and it's not, I would not use the browser as the
interface at all. However, since the browser interface is so popular, I
should still be able to do whatever I want even if it is stupid and insecure.

There must be a way to do this. The print button on the toolbar still
bypasses the dialogue....hmmm

Anyway, if I figure it out, I'll post it here.
 
J

John Timney \(ASP.NET MVP\)

Using IE resource kit you can disable the buttons for print and stop the
user changing setting etc which would solve your specific problem I expect.

There is a cludge that works in IE only - the code is shown below. You
might want to add a bit of div code around the print button that hides it
when the script executes so its not printed. Personally I would avoid this
type of thing but if it does the job then problem solved.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director


<html>

<head>

<SCRIPT LANGUAGE="javascript">

// VALUES: intOLEcmd has these possible values
// OLECMDID_OPEN = 1
// OLECMDID_NEW = 2 warning, this kills IE
windows!
// OLECMDID_SAVE = 3
// OLECMDID_SAVEAS = 4
// OLECMDID_SAVECOPYAS = 5 note: does nothing in IE
// OLECMDID_PRINT = 6 note: give '-1' as param -
no prompt!
// OLECMDID_PRINTPREVIEW = 7
// OLECMDID_PAGESETUP = 8


function ieExecWB( intOLEcmd, intOLEparam )
{

// Create OLE Object
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';

// Place Object on page
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);

// if intOLEparam is not defined, set it
if ( ( ! intOLEparam ) || ( intOLEparam < -1 ) || ( intOLEparam > 1 ) )
intOLEparam = 1;

// Execute Object
WebBrowser1.ExecWB( intOLEcmd, intOLEparam );

// Destroy Object
WebBrowser1.outerHTML = "";
}

</script>

</head>


<body>

<button onClick="ieExecWB(6, -1)">
Print Me! - No Prompt!
</button>

Some text and other stuff to print


</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top