asp.net - Print page without URL and DateTime Using Javascript - Stack Overflow

I want to print the div tag content by javascript by using the following code.var divToPrint1 = $('

I want to print the div tag content by javascript by using the following code.

var divToPrint1 = $('#PrintDoc').html();
var newWin = window.open('Share Certificate #001', '', 'width=10px,height=10px');
newWin.document.open();
newWin.document.write('<html><body onload="window.print();">' + divToPrint1 + '</body></html>');
newWin.document.close();
setTimeout(function () { newWin.close(); }, 10);

And print code works fine. But now I want to remove the url, date and title from the print by using the javascript code. Is it possible? Can anyone help me to solve the following problem?

I want to print the div tag content by javascript by using the following code.

var divToPrint1 = $('#PrintDoc').html();
var newWin = window.open('Share Certificate #001', '', 'width=10px,height=10px');
newWin.document.open();
newWin.document.write('<html><body onload="window.print();">' + divToPrint1 + '</body></html>');
newWin.document.close();
setTimeout(function () { newWin.close(); }, 10);

And print code works fine. But now I want to remove the url, date and title from the print by using the javascript code. Is it possible? Can anyone help me to solve the following problem?

Share Improve this question asked Mar 18, 2011 at 14:34 AnveshAnvesh 3191 gold badge8 silver badges24 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

You cannot remove the URL and timestamp programmatically. Those options are part of the Print dialog, which cannot be controlled from JavaScript in the page. This choice is entirely up to the user.

You are using IE? IE adds extra information to your print. Although not sure this can be changed through code...

I did find an article on the MSDN site where you can set some behavior, didn't try it out but you can give it a spin.

If you are trying in Chrome, when you click print button at the bottom of the print page there will be "Remove the Header and Footer" checkBox.

Also for other browsers go to print settings and there you will find same settings.. just un-check it

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744291794a4567068.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信