You can add a script to data
variable like so:
var data = '<script>/* CODE */ <\/script>' +
'<table ...>' +
:
'<style...>';
The ending script
tag within a string must somehow be broken, so that it doesn't appear as a literal </script>
. If it does, the script will break, when the tag is found.
Also you need to take care, that quotes within a script string are not breaking the string. Use "
s and escape '
with a backslash when needed.
Actually there are more elegant ways to style a page (or part of it) for printing, you could use for example Media Queries, or link (see media
) a separate stylesheet to style prints.