Wednesday 6 June 2012

Print text area content

<html>
  <head>
    <title>Print TextArea</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    <script type="text/javascript">
      function printTextArea() {
        childWindow = window.open('','childWindow','location=yes, menubar=yes, toolbar=yes');
        childWindow.document.open();
        childWindow.document.write('<html><head></head><body>');
        childWindow.document.write(document.getElementById('targetTextArea').value.replace(/\n/gi,'<br>'));
        childWindow.document.write('</body></html>');
        childWindow.print();
        childWindow.document.close();
        childWindow.close();
      }
    </script>
  </head>
  <body>
    <textarea rows="20" cols="50" id="targetTextArea">
      TextArea value...
    </textarea>
    <input type="button" onclick="printTextArea()" value="Print Text"/>
  </body>
</html>

1 comment:

Disable Caching Drupal 8

1. Copy and rename the sites/example.settings.local.php to sites/default/settings.local.php: $ cp sites / example . settings . local . ph...