473,466 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

'Save as HTML' button

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.
Jul 23 '05 #1
3 11614
00steve wrote:
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
Jul 23 '05 #2
J Wynia wrote:
00steve wrote:
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


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.
Jul 23 '05 #3
00steve wrote:
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.


MSIE only:

if (document.execCommand) {
document.execCommand("saveas",true);
}

See:
http://msdn.microsoft.com/workshop/a...xeccommand.asp
http://msdn.microsoft.com/workshop/a...nts/saveas.asp

ciao, dhgm
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: David W. Simmonds | last post by:
Is there a way I can have a button on a ASP.NET form that when clicked will allow the user to save the image to a file on the client side? I know that the user can simply rclick the image and...
4
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
11
by: Thomas Magma | last post by:
I have a simple JavaScript application that will generate some text type data for the end user. Is it possible to have a button that will allow them to save this information to a text file? ...
12
by: =?Utf-8?B?RnJlZU5FYXN5?= | last post by:
Hello, the scenario: There's an ASPX page which shows some text and has three buttons at the bottom: Save, Print and Close. Print and close is done by javascript. But how can I save the page...
3
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
4
by: anilareddy | last post by:
Hi all, I have a problem in my project. I have developed a small page like this. Now after the save button is clicked, the data which is entered should be stored in the database. I'm attaching the...
5
by: KingdomHeart | last post by:
I am very newbie in ajax, so please forgive me if my question are so dump. I want to create a box where user can type a message and when they click "Save" button. That text will be save. I got the...
2
by: sowmram | last post by:
Hi, I'm trying to create a site very similar to wiki, where you can edit, save.. Generally update data for the future use... This particular program I wanna do it using javascripts... Please...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.