2011-01-19 11 views
5

मैं टेक्स्ट क्षेत्र से टेक्स्ट प्रिंट करना चाहता हूं।टेक्स्टरेरा से टेक्स्ट कैसे मुद्रित करें?

मेरे पास एक टेक्स्टरेरा है जो उपयोगकर्ता द्वारा पाठ को अपडेट किया जा सकता है। जब उपयोगकर्ता टेक्स्टरेरा से टेक्स्ट अपडेट करते हैं और फिर अपडेट किए गए टेक्स्ट को प्रिंट करते हैं तो पेज पर प्रिंट किया जा सकता है। और यह पाठ टेक्स्ट पेज पर प्रिंट पेज पर प्रिंट किया जा सकता है।

कृपया कोई समाधान सुझाएं।

धन्यवाद

उत्तर

15

मुझे लगता है कि मुझे वह मिला है जो आप पूछ रहे हैं।

<html> 
    <head> 
    <title>Print TextArea</title> 
    <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> 

मूल रूप से यह एक और चाइल्ड विंडो खोलने के लिए और उस पर जावास्क्रिप्ट प्रिंट पर अमल ताकि पाठ क्षेत्र और अन्य बातों के मुद्रित नहीं मिलता होगा: इसे आज़मा कर देखें।

+0

धन्यवाद, यह मेरे लिए ठीक काम करता है। – Jayashri

+0

खुशी है कि यह काम करता है :) – intellidiot

+0

बीटीडब्ल्यू, आपके प्रश्न में एक और टैग 'जावास्क्रिप्ट' जोड़ा। – intellidiot

संबंधित मुद्दे