ColdFusion in Context: Get Documents

You've been in this situation before. A site makes a document publicly available, but the fancy interface insists on dumping the document directly into your browser. Searching a large document over the Web may be slow or impossible. It may not be possible to cut and paste text to help you compose a summary of its contents. In short, you don't have a document; you have wallpaper that you can't examine effectively.

Consider a Solution

If you had a regular link, you could right-click the link and save the file for more effective use. However, the site's interface only provides buttons or javascript. You don't have a link...or do you?

You can generally determine the effective link by looking at the URL after the document begins to display, or you view the document properties to determine the URL. But so what? If you paste this URL into the browser, you'll be stuck with the same process as before: the browser will try to open the document.

One answer is to use a form to create a link to the URL. That's the tack taken by this project.

Code

Create a page; call it getdoc.cfm. Provide instructions, set a parameter for the form variable, and create a simple form that has a text input and a submit button. After the form, add a link whose destination is the value of the form variable.

If you can't right-click on a link, follow it, copy it from the browser window or page properties, then...
<p>
<cfparam name="form.Getdoc" default="">
<form method="post">
Copy the URL, then paste it below as text and Submit.<br>
<input name="Getdoc" type="text" size="75">
<input name="Doit" type="submit" value="Submit">
</form>
When the URL appears below, right-click it to see a menu that lets you save it to your computer.
<p>
<cfoutput><a href="#form.Getdoc#">#form.Getdoc#</a></cfoutput>

Execute

Browse getdoc.cfm. It starts off with no visible link at all. (If you view source, you'll see an empty link.) Enter a URL and press Submit. (If the URL lacks a true filename - perhaps it's a default name such as index.cfm - add the appropriate filename before pressing Submit.) A link will appear; its description and target will match the URL you entered in the input field. The input field will empty out for the next document.

Right-click the link. If you select "save target as" (or "save link as" for Netscape browsers), you can save the document for more effective review. If the problem is having the document come up in a small frame or with no window controls, you can use the same answer. Simply fill in the URL, press submit, right-click on the link, and select "Open in new window". By the way, this works just fine from your desktop development environment. You don't have to deploy this tip on a public Web server to take advantage of it. =Marty=