{"id":207,"date":"2012-02-26T07:46:02","date_gmt":"2012-02-26T07:46:02","guid":{"rendered":"http:\/\/ntspl.co.in\/blog\/?p=207"},"modified":"2024-09-18T10:57:33","modified_gmt":"2024-09-18T10:57:33","slug":"how-to-print-a-div-with-browser-compatibility","status":"publish","type":"post","link":"https:\/\/www.ntspl.co.in\/blog\/how-to-print-a-div-with-browser-compatibility\/","title":{"rendered":"How to print a div (with browser compatibility)"},"content":{"rendered":"<p>Do you know how to print a div? Read this simple and step by step article and get the code that will print a div with browser\u2019s compatibility.1.<strong>Create a html page<\/strong><\/p>\n<p>2.<strong>Link print.js file <\/strong><\/p>\n<pre class=\"code-structure\"><code>function printSelection(node) {\r\n\r\n\tvar content = node.innerHTML\r\n\r\n\tvar pwin = window.open('', 'print_content', 'width=700px,height=900px');\r\n\r\n\tpwin.document.open();\r\n\r\n\tpwin.document.write('&lt;html&gt;&lt;body onload=\"window.print()\"&gt;&lt;img src=\"http:\/\/demo1.ntsplhosting.com\/print-js\/vedanta_logo.jpg\" width=\"171\" height=\"80\"&gt;' + content + '&lt;\/body&gt;&lt;\/html&gt;');\r\n\r\n\tpwin.document.close();\r\n\r\n\tsetTimeout(function() { pwin.close(); }, 5000);\r\n\r\n}\r\n<\/code><\/pre>\n<p><strong>3.Add a div with id=&#8217;printtext&#8217;<\/strong><\/p>\n<p><strong>4.write text with in div<\/strong><\/p>\n<p><strong>5.close div<\/strong><\/p>\n<p><strong>6.add a button <\/strong><\/p>\n<pre class=\"code-structure\"><code>\r\n&lt;input id=\"Button1\" type=\"button\" value=\"Print\" onclick=\"printSelection(document.getElementById('printtext'));return false\" \/&gt;\r\n<\/code><\/pre>\n<p><strong>7.Your page like:<\/strong><\/p>\n<pre class=\"code-structure\"><code>\r\n&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\"&gt;\r\n\r\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"&gt;\r\n\r\n&lt;head&gt;\r\n\r\n&lt;title&gt;Print Demo Create By Sameer Kumar Das&lt;\/title&gt;\r\n\r\n&lt;script src=\"print.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;\r\n\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;input id=\"Button1\" type=\"button\" value=\"Print\" onclick=\"printSelection(document.getElementById('printtext'));return false\" \/&gt;\r\n\r\n&lt;div id='printtext'&gt;\r\n\r\nasdasdasd asd\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Do you know how to print a div? Read this simple and step by step article and get the code that will print a div with browser\u2019s compatibility.1.Create a html page 2.Link print.js file function printSelection(node) { var content = node.innerHTML var pwin = window.open(&#8221;, &#8216;print_content&#8217;, &#8216;width=700px,height=900px&#8217;); pwin.document.open(); pwin.document.write(&#8216;&lt;html&gt;&lt;body onload=&#8221;window.print()&#8221;&gt;&lt;img src=&#8221;http:\/\/demo1.ntsplhosting.com\/print-js\/vedanta_logo.jpg&#8221; width=&#8221;171&#8243; height=&#8221;80&#8243;&gt;&#8217; + content [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":1535,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3,20,22,32],"tags":[56,62,166,208,241,252,280,310,330,380],"class_list":["post-207","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-dot-net","category-jquery-javascript","category-ntspl","category-tutorials","tag-aspnet","tag-awarded-website-design-company","tag-how-to-print-a-div","tag-jquery-and-javascript","tag-ntspl","tag-odisha-hosting","tag-print-div","tag-seo-odisha","tag-sql-server","tag-website-development"],"acf":{"custom_meta_title":"How to Print a div with Browser Compatibility? | NTSPL","meta_description":"Do you know how to print a div? Read this simple and step by step article and get the code that will print a div with browser\u2019s compatibility.","meta_keyword":"print a div, printing a div with browsers compatibility","other_meta_tag":"<meta property=og:locale content=\"en-IN\" \/>\r\n<meta property=og:type content=\"website\" \/>\r\n<meta property=og:title content=\"How to Print a div with Browser Compatibility? | NTSPL\"\/>\r\n<meta property=og:description content=\"Do you know how to print a div? Read this simple and step by step article and get the code that will print a div with browser\u2019s compatibility.\"\/>\r\n<meta property=og:url content=\"https:\/\/www.ntspl.co.in\/blog\/how-to-print-a-div-with-browser-compatibility\"\/>\r\n<meta property=\"og:image\" content=\"https:\/\/www.ntspl.co.in\/blog\/wp-content\/uploads\/2012\/02\/how-to-print-a-div-with-browser-compatibility.jpg\"\/>\r\n<meta property=og:site_name content=NTSPL \/>\r\n<meta name=\"twitter:site\" content=\"@NTSPL\">\r\n<meta name=twitter:card content=\"summary\" \/>\r\n<meta name=twitter:description content=\"Do you know how to print a div? Read this simple and step by step article and get the code that will print a div with browser\u2019s compatibility.\"\/>\r\n<meta name=twitter:title content=\"How to Print a div with Browser Compatibility? | NTSPL\"\/>"},"_links":{"self":[{"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/posts\/207"}],"collection":[{"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":7,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":10584,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/posts\/207\/revisions\/10584"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/media\/1535"}],"wp:attachment":[{"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}