Click here to Skip to main content
15,886,634 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to open new print dialog with existing data. i write follwing code

JavaScript
print: function (dialog) {
       var printW = window.open("");
       var d = $("#" + dialog);
       var html = "<link href='" + baseURL + "Content/Styles/ui-lightness/jquery-ui.min.css' rel='stylesheet'/><link href='" + baseURL + "Content/Styles/ui-lightness/jquery.ui.theme.css' rel='stylesheet'/><link type=\"text/css\" rel=\"stylesheet\" href=\"" + baseURL + "Content/Styles/Site.css\">";
       html += "<div class=\"ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable\" style=\"outline: 0px none; z-index: 1002; position: absolute; height: auto; width: 800px; display: block;\" role=\"dialog\" aria-labelledby=\"ui-id-1\">";
       html += "<div id=" + dialog + " class=\"inner ui-dialog-content ui-widget-content\" style=\"width: auto;height:auto;\" scrolltop=\"0\" scrollleft=\"0\">";
       d.find(".buttons").hide();
       html += d.html();
       html += "</div>";

       printW.document.write(html);
       printW.document.close();
       printW.focus();
       printW.print();
       d.find(".buttons").show();
       printW.close();
   }


the above code working correct for Internet Explorer but it's not working with chrome browser.

error occurred for this line
printW.document.write(html);

and error is: undefined type document for PrintW.
please help

[Edit member="Tadit"]
Correct pre tags.
[/Edit]
Posted
v2

1 solution

Demo - [Demo] Window Open and Print Preview[^].

In this demo, I removed all the dependent codes and just tried to print Hello World in the Div and it is working perfectly. You can check.

So, my suggestion to you is that, look at the Developer Tool Console (like FireBug console in FireFox) and find out whether any errors are listed or not. If listed, then correct them.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900