From d14eb7837e9a7248316aad72a8080d26192df59d Mon Sep 17 00:00:00 2001 From: Ilia Date: Tue, 10 Dec 2013 23:22:06 +0300 Subject: [PATCH] Extended functionality of jQuery jasonday / printThis plugin, to embed JavaScript to child (print) iframe This modification is an example of how to extend plugin's functionality, by adding 'importJS' and 'loadJS' options. --- Ilia Rostovtsev | 134 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 Ilia Rostovtsev diff --git a/Ilia Rostovtsev b/Ilia Rostovtsev new file mode 100644 index 0000000..fe0e4ac --- /dev/null +++ b/Ilia Rostovtsev @@ -0,0 +1,134 @@ +(function ($) { + var opt; + $.fn.printThis = function (options) { + opt = $.extend({}, $.fn.printThis.defaults, options); + var $element = this instanceof jQuery ? this : $(this); + + var strFrameName = "printThis-" + (new Date()).getTime(); + + if(window.location.hostname !== document.domain && navigator.userAgent.match(/msie/i)){ + // Ugly IE hacks due to IE not inheriting document.domain from parent + // checks if document.domain is set by comparing the host name against document.domain + var iframeSrc = "javascript:document.write(\"\")"; + var printI= document.createElement('iframe'); + printI.name = "printIframe"; + printI.id = strFrameName; + printI.className = "MSIE"; + document.body.appendChild(printI); + printI.src = iframeSrc; + + } else { + // other browsers inherit document.domain, and IE works if document.domain is not explicitly set + var $frame = $("