asapltda Posted December 4, 2023 Share Posted December 4, 2023 Good afternoon, I want to include the attached files in the component. Can someone help me? Thank you for your attention index.html script.js styles.css Link to comment Share on other sites More sharing options...
Sherzod Posted December 5, 2023 Share Posted December 5, 2023 8 hours ago, asapltda said: I want to include the attached files in the component. Can someone help me? Hello, For example: 1. Copy the files (script.js, styles.css) to the files directory. 2. UnimHTMLFrame.HTML -> <!DOCTYPE html> <html> <head> <title>Imprimir Texto</title> <script src="files/script.js"></script> <link rel="stylesheet" href="files/styles.css"> </head> <style> .container { text-align: center; margin-top: 50px; } #textToPrint { font-size: 18px; margin-top: 20px; border: 1px solid #000; padding: 10px; } </style> <body> <div class="container"> <button id="printButton">Imprimir Texto</button> <div id="textToPrint">Este es el texto que se imprimirá.</div> </div> <!--<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>--> </body> </html> <script> $(document).ready(function(){ $('#printButton').on('click', function(){ var text = $('#textToPrint').text(); printText(text); }); }); function printText(text) { var printWindow = window.open('', '_blank'); printWindow.document.write('<html><head><title>Texto a Imprimir</title></head><body>'); printWindow.document.write('<h1>' + text + '</h1>'); printWindow.document.write('</body></html>'); printWindow.document.close(); printWindow.print(); } </script> By the way, I commented out the line: <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> 1 Link to comment Share on other sites More sharing options...
Recommended Posts