473,411 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

'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 11610
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.