can't use javascript to print in IE6

F

fredd00

Hi

I have an aspx page that has a datagrid and a print button

i have a javascript function :

function PrintPage(){

if (window.print) {alert('print');window.focus(); window.print(); }
else {alert('This script does not work in your browser');}
//history.back();
//return false;
}

on the print buton click i have
private void btnPrint_Click(object sender,
System.Web.UI.ImageClickEventArgs e) {

pnlTopButtons.Visible = false; // hide some buttons
pnlPrintButtons.Visible = false;// hide some buttons
pnlUsdQty.Visible=false; // hide some buttons
Page.RegisterStartupScript("jsPrint","<script
language=JavaScript>javascript:printPage();</script>");
}

the thing is :
<script language=JavaScript>javascript:printPage();</script>
is in the page , is the last thing before </form>

the javascript is being called, the alert is fired but not the print
part of the script , no printer dialog box , but in firefox the dialog
box is being displayed.

is it a bug with IE ?, is there a work around ?

thanks i really need this
 
G

Guest

Code looks correct to me...

what happense , if you remove all other lines and use only window.print();
in the PrintPage() function ?

I think, the only way to find this would be step by step debugging, unless
there is a known MS IE bug. :)
 
G

Guest

But it still works in firefox.. ?.. strange!

I tried the code you posted in first post (only the PrintPage() function ,
not the post back etc) in IE version 6.0.2900.2180 on Win XP SP2 and it
worked just fine..

you may want to try in a different machine, compare IE versions etc
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top