Вывод на печать содержимого textarea
Здравствуйте! Возникла необходимость распечатки посетителем содержимого textarea, особым шрифтом.
Вот что получилось: <style><!-- @font-face { font-family: Allegretto Script Two; src: url(fonts/Allegretto Script Two.ttf); } textarea { font-family: Allegretto Script Two, 'Comic Sans MS', cursive; font-size: 30pt;} }--></style> <p> <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('Text').value.replace(/\n/gi,'<br>')); childWindow.document.write('</body></html>'); childWindow.print(); childWindow.document.close(); childWindow.close(); } </script> </p> <p><textarea id="Text" cols="10" name="propisi" rows="10" onfocus="this.value=''; setbg('#e5fff3');" onblur="setbg('white')"></textarea></p> <p><input onclick="printTextArea()" type="button" value="Печать" /></p> Шрифт подключается, в самой форме отображается корректно. Но при выводе на печать он меняется на стандартный. Т.е. на бумагу выходит обычный шрифт. Как решить проблему, подскажите. |
<style><!-- @font-face { font-family: Allegretto Script Two; src: url(fonts/Allegretto Script Two.ttf); } textarea { font-family: Allegretto Script Two, 'Comic Sans MS', cursive; font-size: 30pt;} }--></style> <p> <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.body.style.fontFamily = 'Comic Sans MS'; childWindow.document.body.style.fontSize = '32pt'; //////////////////////////////////////////////// childWindow.document.write(document.getElementById('Text').value.replace(/\n/gi,'<br>')); childWindow.document.write('</body></html>'); childWindow.print(); childWindow.document.close(); childWindow.close(); } </script> </p> <p><textarea id="Text" cols="10" name="propisi" rows="10" onfocus="this.value=''; setbg('#e5fff3');" onblur="setbg('white')"></textarea></p> <p><input onclick="printTextArea()" type="button" value="Печать" /></p> |
Спасибо, Маэстро!
Теперь работает. |
Часовой пояс GMT +3, время: 04:22. |