473,587 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can't use javascript to print in IE6

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.I mageClickEventA rgs e) {

pnlTopButtons.V isible = false; // hide some buttons
pnlPrintButtons .Visible = false;// hide some buttons
pnlUsdQty.Visib le=false; // hide some buttons
Page.RegisterSt artupScript("js Print","<script
language=JavaSc ript>javascript :PrintPage();</script>");
}

the thing is :
<script language=JavaSc ript>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

Nov 19 '05 #1
4 1780
There is no window.print property in IE.

Eliyahu

"fredd00" <fr************ *@gmail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
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.I mageClickEventA rgs e) {

pnlTopButtons.V isible = false; // hide some buttons
pnlPrintButtons .Visible = false;// hide some buttons
pnlUsdQty.Visib le=false; // hide some buttons
Page.RegisterSt artupScript("js Print","<script
language=JavaSc ript>javascript :PrintPage();</script>");
}

the thing is :
<script language=JavaSc ript>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

Nov 19 '05 #2
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. :)

"fredd00" wrote:
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.I mageClickEventA rgs e) {

pnlTopButtons.V isible = false; // hide some buttons
pnlPrintButtons .Visible = false;// hide some buttons
pnlUsdQty.Visib le=false; // hide some buttons
Page.RegisterSt artupScript("js Print","<script
language=JavaSc ript>javascript :PrintPage();</script>");
}

the thing is :
<script language=JavaSc ript>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

Nov 19 '05 #3
if i only leave window.print() , nothing happens
the page is loaded and that's it

Nov 19 '05 #4
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

"fredd00" wrote:
if i only leave window.print() , nothing happens
the page is loaded and that's it

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9427
by: Marcus Bjorke | last post by:
I use a print link that causes a problem with Opera 7. The link looks like this <a href="javascript:parent.frames.mainFrame.print()">Print this page</a> I also used <a href="javascript:print()">Print this page</a> and it also worked with most browsers. I realize that it only works if you have Microsoft Windows versions for PC but that is...
2
1219
by: bentley | last post by:
I need to print a browser page and configure the print dialog settings.  I am using the JavaScript window object with the print method (window.print() ).  From what I understand and have read in order to programmatically change options print dialog I must create an Active-X object that will configure the print dialog (I only ne an IE...
0
6423
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to be modified: if(e.CommandName =="Print") { string parsedreceipt = null; parsedreceipt = DecodeReceipt (e.Item.Cells.Text); Session =...
6
4858
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still...
3
1830
by: haakern | last post by:
Hi, In an aspx page, I've got a TreeView and a detail form and a print button. When the user clicks on the print button, I'd like to collapse the TreeView and send the page to the printer. Using Javascript, the print is easy: <asp:ImageButton ID="btnPrint" runat="server" AlternateText="Print" ImageUrl="~/images/print.gif"...
3
4220
by: Jlcarroll | last post by:
Hi, I am building a web page.and have a simple javascript menu... I call the javascript menu within a div block that my print sytlesheet has set as a display: none;, well all the content in that block doesn't show up, EXCEPT the javascript is still getting run... <div class="menu"> <!--*****************These lines load in the
1
2565
by: KRISHNA PRAVI | last post by:
the error is "runtime error object expected" here is the code....................................................................................... <script language="javascript" src="../Scripts/calender.js"></script> </HEAD> <body bgColor="white" MS_POSITIONING="GridLayout"> <form id="Form1" style="LEFT: 0px; POSITION: absolute; TOP:...
5
15986
by: maminx | last post by:
hello all, i want to call window print preview (in browser, File - Print Preview) by javascript, this is the code function printpreview() { var OLECMDID = 7; /* OLECMDID values: * 6 - print * 7 - print preview * 1 - open window
4
3465
by: maminx | last post by:
hello all. i have html page to be printed out..it's generated by the button print like below <input type="button" name="btn_print" value="Print Invoice" onClick="javascript:window.print();"> of course, the button will shown to the page when it's printed.. but i don't want that button shown when user print the page (paper) or when the user...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5713
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.