Javascript.RU

Создать новую тему Ответ
 
Опции темы Искать в теме
  #1 (permalink)  
Старый 24.07.2014, 14:54
Новичок на форуме
Отправить личное сообщение для Jack-0504 Посмотреть профиль Найти все сообщения от Jack-0504
 
Регистрация: 24.07.2014
Сообщений: 2

Вывод на печать содержимого 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>

Шрифт подключается, в самой форме отображается корректно. Но при выводе на печать он меняется на стандартный. Т.е. на бумагу выходит обычный шрифт.
Как решить проблему, подскажите.
Ответить с цитированием
  #2 (permalink)  
Старый 24.07.2014, 15:53
Профессор
Отправить личное сообщение для Маэстро Посмотреть профиль Найти все сообщения от Маэстро
 
Регистрация: 02.07.2010
Сообщений: 642

<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>
Ответить с цитированием
  #3 (permalink)  
Старый 24.07.2014, 16:13
Новичок на форуме
Отправить личное сообщение для Jack-0504 Посмотреть профиль Найти все сообщения от Jack-0504
 
Регистрация: 24.07.2014
Сообщений: 2

Спасибо, Маэстро!
Теперь работает.
Ответить с цитированием
Ответ



Опции темы Искать в теме
Искать в теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Вывод содержимого ячейки массива = значению счетчика cccp.world Events/DOM/Window 5 30.10.2013 09:06
Печать содержимого дочернего окна adamenko.artem ExtJS 1 20.09.2013 21:04
Вывод вордовского документа на печать. Dashyxa Общие вопросы Javascript 2 10.06.2012 23:46
Вывод содержимого текстового поля по onChange Ilyich Events/DOM/Window 2 08.06.2011 18:37
Вывод изображения на печать. can2zia Events/DOM/Window 0 10.01.2011 14:39