'Save as HTML' button

0

00steve

Hi,
I was wondering if anyone knew how to go about having a "save as HTML"
option incorporated within a page. (I know the option is available
from the file menu from within IE, but a client has requested that a
button be used instead)

Does anyone know how to go about accomplishing this? The possibility
of IE specific code is available, as IE 6 is assumed as the client.

Thanks in advance.
 
J

J Wynia

00steve said:
Hi,
I was wondering if anyone knew how to go about having a "save as HTML"
option incorporated within a page. (I know the option is available
from the file menu from within IE, but a client has requested that a
button be used instead)

Does anyone know how to go about accomplishing this? The possibility
of IE specific code is available, as IE 6 is assumed as the client.

Thanks in advance.

What you're looking for is this snippet:

window.location = "view-source:" + window.location.href;

Wrap it in a function and tie it to your button and you should be golden.

This works on both major browser platforms in their current versions.

J Wynia
Myriad Intellect, Inc.
www.myriadintellect.com
 
J

J Wynia

J said:
What you're looking for is this snippet:

window.location = "view-source:" + window.location.href;

Wrap it in a function and tie it to your button and you should be golden.

This works on both major browser platforms in their current versions.

J Wynia
Myriad Intellect, Inc.
www.myriadintellect.com

Sorry, I was thinking about something else and responded with the above,
which isn't what you asked. That will give you access to the raw HTML,
but not to save it. Saving it requires client-side permission to the
filesystem, which is going to be fairly difficult without control of
those systems to loosen security restrictions.

I'd personally push for "Email this report" or "Download a PDF version"
or "Download a Word version" instead of "Save as HTML". Using either
OpenOffice's API or the MS Office HTML->Word hack (see below), you can
pretty easily create either other format on the fly from arbitrary HTML.

The HTML->Word hack relies on the fact that modern versions of Office
can open HTML transparently. If you save an HTML file as file.doc and
open it in Office, it is just transparently converted and the user
doesn't see any difference. This hack is particularly useful if what
you're trying to save doesn't include images, etc. which tend to
complicate this hack a bit.

Incidentally, this hack also works for whipping up Excel spreadsheets as
HTML tables and sending them as .xls files.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top