Cross-browser printing team?

I want to know if there is any cross-browser print code, that is, if I need something else, then simply:

//print page $('.print').click(function() { window.print(); return false; }); 

I found it for bookmarks, and therefore I was more worried about printing, but did not find anything useful on Google.

following code for cross bookmark browser

 //bookmark page $("a.bookmark").click(function(e) { e.preventDefault(); // this will prevent the anchor tag from going the user off to the link var bookmarkUrl = this.href; var bookmarkTitle = this.title; if (window.sidebar) { // For Mozilla Firefox Bookmark window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,""); } else if( window.external || document.all) { // For IE Favorite window.external.AddFavorite( bookmarkUrl, bookmarkTitle); } else if(window.opera) { // For Opera Browsers $("a.jQueryBookmark").attr("href",bookmarkUrl); $("a.jQueryBookmark").attr("title",bookmarkTitle); $("a.jQueryBookmark").attr("rel","sidebar"); } else { // for other browsers which does not support alert('Your browser does not support this bookmark action'); return false; } }); 
+6
source share
3 answers

window.print () is the de facto standard. (it has been supported since IE4 / Netscape 4).

While you're on it, be sure to check how you can customize how your page looks when it is printed using special CSS CSS styles .

+22
source

window.print() will do the job.

+2
source

This is a common way. This is not an official part of the house. First I must verify its existence.

0
source

Source: https://habr.com/ru/post/897551/


All Articles