From 9451a2c09f2005cbf5bdb893eeccead5b90844df Mon Sep 17 00:00:00 2001 From: James Oakley Date: Wed, 12 Dec 2012 10:54:59 -0800 Subject: [PATCH] Copy doctype from document when generating html. This keeps the browser from entering quirks mode, fixing #24. Code based on http://stackoverflow.com/questions/6088972/get-doctype-of-an-html-as-string-with-javascript --- jQuery.printElement/jquery.printElement.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jQuery.printElement/jquery.printElement.js b/jQuery.printElement/jquery.printElement.js index 96f8a3e..094d3c0 100644 --- a/jQuery.printElement/jquery.printElement.js +++ b/jQuery.printElement/jquery.printElement.js @@ -150,6 +150,19 @@ var elementHtml = _getElementHTMLIncludingFormElements(element); var html = new Array(); + + // Copy doctype if it's present + if (document.doctype) { + var node = document.doctype; + html.push( + "' + ); + } html.push('' + opts["pageTitle"] + ''); if (opts["overrideElementCSS"]) { if (opts["overrideElementCSS"].length > 0) {