printThis icon indicating copy to clipboard operation
printThis copied to clipboard

JavaScript extended functionality for jQuery printThis plugin

Open iliaross opened this issue 12 years ago • 6 comments

This modification is an example of how to extend plugin's functionality, by adding 'importJS' and 'loadJS' options. This will let the user to chose whether to load parent page's .js files and whether to execute custom JavaScript code.

iliaross avatar Dec 10 '13 20:12 iliaross

Can you set up a jsfiddle with a potential use case? I have concerns with whether this will work in IE; specifically, IE8.

jasonday avatar Dec 11 '13 01:12 jasonday

Jason, I have checked and it worked in IE11 and most likely will work in version 9 and 10. I can't setup jsFiddle for you with the particuar example as it takes to much time but can tell you when I needed it.

We use printThis to print certain part of pages. When you use dynamic libraries to arrange content (like Masonry or Isotope), for example to force all tables with different height, to be positioned right below each other, you need to reload those for print version, because you change the font's size, and other formatting for print version almost everytime. When you do it, the content's height is also changing and you need to reload js to make it look correct on the print verstion.

Simplest way to check it is just to add alert to the code and run accros all browsers:

$("#mySelector").printThis({ loadJS: 'alert("JS has been loaded");' });

Try it it should work everywhere, if not, tell me where it's not working and I will try to debug to make it work!

iliaross avatar Dec 11 '13 06:12 iliaross

Hi rostovstev, I'd like to merge this pull request, however I am requiring that the author/reporter provide a demo of any changes (or bugs) in jsfiddle.net or jsbin.com for review & browser testing.

jasonday avatar Jan 27 '14 04:01 jasonday

Jason, as the code uses document.write, it's disallowed on jsFiddle.net and returns an error:

document.write is disallowed in JSFiddle envioriment and might break your fiddle.

iliaross avatar Jan 28 '14 10:01 iliaross

Can you try jsbin.com?

On 1/28/2014 5:43 AM, Ilia wrote:

Jason, as the code uses document.write, it's disallowed on jsFiddle.net and returns an error:

|document.write is disallowed in JSFiddle envioriment and might break your fiddle. |

— Reply to this email directly or view it on GitHub https://github.com/jasonday/printThis/pull/21#issuecomment-33467614.

jasonday avatar Jan 28 '14 21:01 jasonday

No sure what you want, Jason! It will not work: http://jsbin.com/IkaYOFA/1 Do it on your local computer - it will work.

iliaross avatar Jan 29 '14 07:01 iliaross