aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Print Text Area Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Print Text Area" Watch "Print Text Area" New topic
Author

Print Text Area

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 117
I am trying to print a text area using JQuery. Here is my code, I am new to JQuery, any insight on what and how to code could really help. Thanks for your time.
Luke.



Since I am not able to attach the file(don't know why, may be security reasons) I am copy pasting the script file:

jquery.printElement.js






Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

What's the problem? Is that a plugin you found somewhere?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 117
Thanks for the reply Bear. My problem is I am not able to print, it is giving me javaScript errors. Not able to print. Is there any other way using jQuery how I could print a text area from a html page. The code I pasted was a script file I found online, may be I did not know how to use it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

That's way too much script for someone to analyze for you. I suspect it would be best to either need to narrow the problem down and ask more specific questions, or contact the author of the script for help.
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 117

Thanks Bear, lets leave the script code. Overall, do you have any suggestions if I have to print just the text area using Jquery?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Depends how fancy you want to get. Seems pretty easy to do the basic thing:
  • Grab the content of a text area.
  • Create a hidden iframe.
  • Write the content to the iframe, along with a script tag that calls window.print()

  • Luke Zechariah
    Ranch Hand

    Joined: Sep 27, 2005
    Posts: 117

    Thanks Bear, I was able to solve this with the following code, it is working fine if I have normal javaScript but I am missing something with JQuery. Please help. Thanks, Lz.



    JQuery Script Code:
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60050
        
      65

    This line:is not the way to deal with a jQuery wrapped set.
     
    jQuery in Action, 2nd edition
     
    subject: Print Text Area
     
    Similar Threads
    Is there something better then event.pageX/Y?
    Is it possible to put a button inside autocomplete in jquery ui plugin?
    My First Real jQuery Plugin - Feedback
    JQuery.UI Dialog & $().load() & JavaScript
    document.forms[0].submit(); throws Invalid Argument in IE