最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin6浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论