Some CFML Stuffs Me Do

From: Ken (SHIELDSIT) 5 May 2011 00:02
To: ALL1 of 75

Peter. I have a few CF questions if you don't mind!

 

1. This one is probably more html or javascript, but is there a snippit of code that lets you print the page? Like put a "print this page" button on the site and let it print instead of having to hit Ctrl-P?

 

2. How can I remove the URL from a printed page?

 

ta you handsome man!

From: Ken (SHIELDSIT) 5 May 2011 00:03
To: Peter (BOUGHTONP) 2 of 75
This was too you, but I'm too dumb to pick you from a list!
From: steve 5 May 2011 00:50
To: Ken (SHIELDSIT) 3 of 75
javascript code:
window.print();


Will tell the browser to start the printing process; it'll usually bring up the print dialogue as if you have pressed CTRL+P. I don't think there's a way to just send a page to the printer without user invention, at least, I hope there isn't. Troll sites would be even more annoying.

You could, for instance, have an image (saying 'print this page!! :C') -

html code:
<img src="http://miffle.com/image.jpg" onClick="window.print();" />


Clicking that would start things. You're correct in saying this is all Javascript.

Regarding not printing the URL on the page, that's browser dependant. I came up against this making invoices for Rowdydow more automated: Chrome currently has no options for configuring the printed URL, page title and page number.

Internet Explorer does, and will remember the settings. Before I had it properly automated with a C# application, I had the Chrome extension to open a page in an IE tab - and printed it from there (it would remember my previous settings and print no URL).

HTH :)
From: Ken (SHIELDSIT) 5 May 2011 01:03
To: steve 4 of 75
quote:
HTH


Indeed it does, thanks a bunch!
From: Peter (BOUGHTONP) 5 May 2011 01:28
To: Ken (SHIELDSIT) 5 of 75
Bah, you don't have any CFML questions for me, and Steve answered the ones you did ask... though not properly. :@

html code:
<img
    src="http://miffle.com/image.jpg"
    alt="print" 
    title="Click to print this page!"
    style="cursor:pointer"
    onclick="window.print();"
/>


* All image tags should have an alt tag, even if empty.
* Title is a good idea for anything which does something.
* As is setting the cursor to a pointer (though that should be in a class, not an inline style, really).
* The onclick attribute should be all lowercase, because I said so (it works either way).


If you really need to get rid of the URL, you'll have to look into generating PDFs, which browsers don't add their garbage to.
EDITED: 5 May 2011 01:29 by BOUGHTONP
From: steve 5 May 2011 01:29
To: Peter (BOUGHTONP) 6 of 75
At least I remembered the slash at the end :$ The HTML for Rowdydow would make you cry.
From: Peter (BOUGHTONP) 5 May 2011 01:35
To: steve 7 of 75
Please don't make me cry!

I'm already sad enough because I'm having to faff about generating XML so I can transfer data from one database to another because the stupid software doesn't have a real importer that would just let me map the appropriate columns directly, nor does it have a decent API (otherwise I'd create that importer myself), and it's all just a big faffing pain.


Oh, and closing slashes are starting to go out of fashion again now, with people finding out that HTML5 doesn't require them to write as XHTML.

I still prefer them, even though I don't otherwise use XML style, because it makes things more readable when scanning through a bunch of tags.
From: Ken (SHIELDSIT) 5 May 2011 01:56
To: Peter (BOUGHTONP) 8 of 75

Sorry, you were too late and Steve was on the ball!

 

I did figure out how to export my reports to Excel AND PDF files! It's turning into a nice project and the people at work who see it are really excited how it's turning out.

 

Never fear - I'm certain to have more questions for you!

 

Oh - I remember when I used to be really into CF (back in the olden days :)) There were places that would offer you free hosting for developers. Do you supposed you could offer free and/or paid hosting using Railo? Or is it against their TOS?

From: Peter (BOUGHTONP) 5 May 2011 02:19
To: Ken (SHIELDSIT) 9 of 75
Whuh? Railo doesn't have ToS.

It's Open Source, and more specifically it's LGPL which explicitly enforces your freedom to do pretty much whatever you want with it.

There's already several hosting companies... Vivio and Alurium are two major ones, and for free hosting HostMedia offer free US-based hosting (£1 setup fee to deter scammers), and CFML Developer does the same in the UK.

Of course, with all the "cloud" stuff these days, a lot of Railo users are preferring to use Amazon EC2 and similar.
From: Ken (SHIELDSIT) 5 May 2011 02:22
To: Peter (BOUGHTONP) 10 of 75

Sorry I didn't mean ToS, but you understood what I was asking.

 

That would be a good idea to supplement some income for you. Then you could afford a bed!

From: ANT_THOMAS 5 May 2011 02:35
To: Ken (SHIELDSIT) 11 of 75
And a decent internet connection.
From: Ken (SHIELDSIT) 5 May 2011 02:36
To: ANT_THOMAS 12 of 75
Oh yeah, good point. Get rid of that shitty phone connection Peter!
From: Peter (BOUGHTONP) 5 May 2011 03:20
To: Ken (SHIELDSIT) 13 of 75
Been there, done that. Too much effort for very little reward, so makes more sense to leave it to the guys that are already established.

I don't need to afford a bed. I use that one... *gestures* ...over there... oh... and I should probably see about doing so now, since I just realised it's 3:20am. Poo. :(
EDITED: 5 May 2011 03:22 by BOUGHTONP
From: Ken (SHIELDSIT) 5 May 2011 03:24
To: Peter (BOUGHTONP) 14 of 75

:) There are a few of you on here that keep some late hours!

 

You are probably right, I can imagine it's a huge pain in the ass trying to make everyone happy and making sure things are secure enough when dealing with multiple customers on the same server.

From: af (CAER) 5 May 2011 10:23
To: steve 15 of 75
quote:
I don't think there's a way to just send a page to the printer without user invention, at least, I hope there isn't. Troll sites would be even more annoying.
That's exactly why no such way exists.

quote:
Regarding not printing the URL on the page, that's browser dependant.
In practice, true, but CSS3 has methods for controlling stuff like that:

http://www.w3.org/TR/2004/CR-css3-page-20040225/

Not that any browser really supports it yet.
From: Ken (SHIELDSIT) 5 May 2011 20:31
To: ALL16 of 75
You guys are the shit. I just got around to putting the print info on my site and it's working great! Thanks!
From: Ken (SHIELDSIT) 5 May 2011 20:33
To: steve 17 of 75

Hey is there a way to do this?

 

After I click an image and make the page print, make it automatically load a different page?

From: af (CAER) 5 May 2011 21:01
To: Ken (SHIELDSIT) 18 of 75
Surely that's just a case of
JavaScript code:
...
window.print();
window.location = "http://new.url.com";
From: Ken (SHIELDSIT) 5 May 2011 21:02
To: af (CAER) 19 of 75
I will let you know if you win or not! Just one second please!
From: af (CAER) 5 May 2011 21:03
To: Ken (SHIELDSIT) 20 of 75
I suspect the window.print() function returns immediately btw, so the page may well change straight away, rather than after the user clicks OK in the Print dialog.