Results 1 to 7 of 7
Related
-
How to set value to a TEXTAREA ? Forum: Javascript Forum
Replies: 1 -
Limited Textarea Forum: HTML Forum
Replies: 4 -
CSS Print Forum: CSS Forum
Replies: 2 -
Textarea or something Forum: HTML Forum
Replies: 2
-
12-31-2003, 04:18 PM #1
How do you print content of textarea?
I have a "Terms & Conditions" textarea defined on a page and would like to add a button for printing the content of the textarea. Something like this:
<INPUT type="button" value=" Print Terms " onClick="printTerms( document.termsService )">
where termsService is the name of the textarea.
It looks like window.print() doesn't take arguements and will print the entire window. I'm not keen on printing from a popup at this point in time.
What "method" can be used to print the content of the textarea once passed to the function called printTerms()?
Assuming I'm passing it correctly ;-)
W.
-
12-31-2003, 04:57 PM #2
Good question.
Directly, printer access is very limited from the web (I think they fear a new wave of spam that just keeps coming out of your printer) but one thing you can do is to specify an alternate document for printing when a print call is asked for. Its a <link> and looks like -
Code:<link rel="alternate" media="print" href="termsandconditions.html">
If one of our members helps you, please click theicon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?
-
12-31-2003, 05:08 PM #3
Actually "printer spam" is one of our concerns. Don't want to rile our users any more than necessary
Thanks for the "alternate" choice. Our web stats show that IE is overwhelming the browser of choice though I would prefer to have as much cross-browser availability as possible (with as little coding as possible).
hmmm...
Let ya know what I end up doing.
W.
-
12-31-2003, 09:03 PM #4
Does this help any?
http://groups.yahoo.com/group/cold_fusion/message/4490
-
01-02-2004, 10:08 AM #5
Enigma,
Thanks, I ran across that code snippet on another site. While its not the most elegant it will work for me.
Since the window.print() function prints the "current" window, is there a way to print the "child" window?
winId = window.open('','newwin');
winId.print() ?
so that I could make the function call from the main window?
W.
-
01-02-2004, 11:22 AM #6
Survey says....YES!
Here's how I did it:
Main page snippets:
<SCRIPT LANGUAGE="JavaScript" src="popup.js"></script>
<SCRIPT LANGUAGE="JavaScript" src="tools.js"></script>
...
...
<INPUT type="button" value=" Print Terms " onClick="printTerms('termsOfService.html')">
popup.js :
function popup(URL) {
var winRef;
day = new Date();
id = day.getTime();
winRef = eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=350,left = 50,top = 10');");
return winRef;
}
tools.js:
function printTerms(URL) {
var winRef;
winRef = popup5( URL );
winRef.print();
}
Mind you the eval() portion of the popup is a vestige of previous coding. Oddly enough if I remove it I get an error on page.
Any critique is gladly welcomed.
W.
-
01-02-2004, 12:52 PM #7
Thats a pretty nice bit of code. Thanks for coming back and letting us know.
If one of our members helps you, please click theicon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum