You can't control this in javascript, it has to be done at the browser level.
What we've also done is generate a PDF so that you can make the page look the same across all browsers. iTextSharp is a free tool to do this. Just a note, it is kinda unfriendly. There is an example here. Basically, you input HTML and it converts it to a PDF.
Just try the following code.
For this we are using print class like it.
public static void PrintWebControl(Control ctrl)
{
PrintWebControl(ctrl, string.Empty);
}
public static void PrintWebControl(Control ctrl, string Script)
{
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
if (ctrl is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
}
Page pg = new Page();
pg.EnableEventValidation = false;
if (Script != string.Empty)
{
pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
}
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.ResolveUrl("");
frm.Attributes.Add("runat", "server");
frm.Controls.Add(ctrl);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(strHTML);
HttpContext.Current.Response.Write("<script>window.print();</script>");
HttpContext.Current.Response.End();
}
here just change a line in form property and set frm.ResolveUrl(""); so URl is not visible when page is print..i use it successfuly.......
[Edit member="Tadit"]
Pre tags added.
[/Edit]