473,480 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

activating the Save As command by JS

Dear all,

Is there any way to activate the Save As command from Javascript. I
would like to have a "Save as" button on a page which has been
dynamically created (client side using document.writeln) so that the
user can save a copy.
I am working towards cross browser compatibility so any help for any
browser would be good.

I know I could put up a bit of text telling the user what the shortcut
key is but thats not as pretty.

I am also aware that JS does not allow writing to the hard-disk (quite
right too) but hopefully there is a way to do what I'm asking.

Cheers,

Martin

Jul 20 '05 #1
10 2978
On Thu, 19 Feb 2004 12:30:55 +0000, Martin Dale
<md******@landrover.zzcom/no_zz> wrote:
Dear all,

Is there any way to activate the Save As command from Javascript. I
would like to have a "Save as" button on a page which has been
dynamically created (client side using document.writeln) so that the
user can save a copy.
I am working towards cross browser compatibility so any help for any
browser would be good.

I know I could put up a bit of text telling the user what the shortcut
key is but thats not as pretty.

I am also aware that JS does not allow writing to the hard-disk (quite
right too) but hopefully there is a way to do what I'm asking.


Sorry, but there isn't. Furthermore, indicating the shortcut isn't very
cross-browser compatible.

Whilst most browsers will use similar shortcuts and menu layouts to make
life easier for users, you can't guarantee success. Particularly as Opera
users, like me (and others in this group), can redefine shortcuts at will.
You best bet would be to point the user towards their menubar.

By the way, I'm not sure whether saving a generated page will save the
original source code or the resulting output. That too, might depend on
the browser.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2
In article <op**************@news-text.blueyonder.co.uk>,
Michael Winter <M.******@blueyonder.co.invalid> wrote:
On Thu, 19 Feb 2004 12:30:55 +0000, Martin Dale
<md******@landrover.zzcom/no_zz> wrote:
Dear all,

Is there any way to activate the Save As command from Javascript. I
would like to have a "Save as" button on a page which has been
dynamically created (client side using document.writeln) so that the
user can save a copy.
I am working towards cross browser compatibility so any help for any
browser would be good.

I know I could put up a bit of text telling the user what the shortcut
key is but thats not as pretty.

I am also aware that JS does not allow writing to the hard-disk (quite
right too) but hopefully there is a way to do what I'm asking.


Sorry, but there isn't. Furthermore, indicating the shortcut isn't very
cross-browser compatible.

Whilst most browsers will use similar shortcuts and menu layouts to make
life easier for users, you can't guarantee success. Particularly as Opera
users, like me (and others in this group), can redefine shortcuts at will.
You best bet would be to point the user towards their menubar.

By the way, I'm not sure whether saving a generated page will save the
original source code or the resulting output. That too, might depend on
the browser.


No, a browser will never be able to read the source code of a
dynamically created page such as PHP or ASP.

It would have to be dynamically created by the browser if the browser
should have access to the code.
Jul 20 '05 #3
On Thu, 19 Feb 2004 16:16:27 +0100, Sandman <mr@sandman.net> wrote:
In article <op**************@news-text.blueyonder.co.uk>,
Michael Winter <M.******@blueyonder.co.invalid> wrote:
On Thu, 19 Feb 2004 12:30:55 +0000, Martin Dale
<md******@landrover.zzcom/no_zz> wrote:
[...] a page which has been dynamically created (client side using
document.writeln) [...]

[snip]
By the way, I'm not sure whether saving a generated page will save the
original source code or the resulting output. That too, might depend on
the browser.


No, a browser will never be able to read the source code of a
dynamically created page such as PHP or ASP.


Ermm, both I and the OP were referring to generation through JavaScript. I
am well aware that browsers don't receive server-side code, only the
output of it.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #4
Sandman wrote:
In article <op**************@news-text.blueyonder.co.uk>,
Michael Winter <M.******@blueyonder.co.invalid> wrote:

On Thu, 19 Feb 2004 12:30:55 +0000, Martin Dale
<md******@landrover.zzcom/no_zz> wrote:
By the way, I'm not sure whether saving a generated page will save the
original source code or the resulting output. That too, might depend on
the browser.

No, a browser will never be able to read the source code of a
dynamically created page such as PHP or ASP.

It would have to be dynamically created by the browser if the browser
should have access to the code.


I think he is referring to JS-modified pages. And typically what you get
is the original page.
Example:

Page is loaded, you change the innerHTML property of the body tag, and
reload some new data, do a File>Save As and then open the saved page,
you will get the original page.

If you use a document.write, after the page loads, to "regenerate" a new
page, and then File>Save As, you get the generated code.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #5
In article <op**************@news-text.blueyonder.co.uk>,
Michael Winter <M.******@blueyonder.co.invalid> wrote:
By the way, I'm not sure whether saving a generated page will save the
original source code or the resulting output. That too, might depend on
the browser.


No, a browser will never be able to read the source code of a
dynamically created page such as PHP or ASP.


Ermm, both I and the OP were referring to generation through JavaScript. I
am well aware that browsers don't receive server-side code, only the
output of it.


Then I apologize. My mistake. :)

--
Sandman[.net]
Jul 20 '05 #6
Randy Webb wrote:
Sandman wrote:
In article <op**************@news-text.blueyonder.co.uk>,
Michael Winter <M.******@blueyonder.co.invalid> wrote:

On Thu, 19 Feb 2004 12:30:55 +0000, Martin Dale
<md******@landrover.zzcom/no_zz> wrote:
By the way, I'm not sure whether saving a generated page will save
the original source code or the resulting output. That too, might
depend on the browser.


No, a browser will never be able to read the source code of a
dynamically created page such as PHP or ASP.

It would have to be dynamically created by the browser if the browser
should have access to the code.

I think he is referring to JS-modified pages. And typically what you get
is the original page.
Example:

Page is loaded, you change the innerHTML property of the body tag, and
reload some new data, do a File>Save As and then open the saved page,
you will get the original page.

If you use a document.write, after the page loads, to "regenerate" a new
page, and then File>Save As, you get the generated code.

What I actually meant was that in page 1 I open a new window
new_win = open();
then write stuff into that page (based on selections made in page 1)
using document.writeln statements (I use writeln to write the
<html><head> etc too).
When you view the source of this generated page it is just standard HTML
which you can save away to reload another day.

Martin

Jul 20 '05 #7

Martin Dale wrote:
*Dear all,

Is there any way to activate the Save As command from Javascript. I
would like to have a "Save as" button on a page which has been
dynamically created (client side using document.writeln) so that the
user can save a copy.
I am working towards cross browser compatibility so any help for any
browser would be good.

I know I could put up a bit of text telling the user what th
shortcut
key is but thats not as pretty.

I am also aware that JS does not allow writing to the hard-dis
(quite
right too) but hopefully there is a way to do what I'm asking.

Cheers,

Martin *


Try this for IE:
document.execCommand("SaveAs", true);

--
http://www.hibrosoft.co

----
Andy_

Jul 20 '05 #8
"Andy_p" <An***********@mail.forum4designers.com> wrote in message
news:An***********@mail.forum4designers.com...

Martin Dale wrote:
*Dear all,
Andy_p


If you are trying to respond to someone on Usenet it would be a good
idea to use posting software that builds a References header for your
message in accordance with RFC 1036 -"Standard for Interchange of USENET
Messages" (1987). Which means going somewhere other than
forum4designes.com.

Richard.
Jul 20 '05 #9
Richard Cornford wrote:
"Andy_p" <An***********@mail.forum4designers.com> wrote in message
news:An***********@mail.forum4designers.com...
Please shorten your attribution since that makes
threads with your postings easier legible:
<http://www.netmeister.org/news/learn2quote1.html#ss1.1>
If you are trying to respond to someone on Usenet it would be a good
idea to use posting software that builds a References header for your
message in accordance with RFC 1036 -"Standard for Interchange of USENET
Messages" (1987). Which means going somewhere other than
forum4designes.com.


The References header of his posting is OK.
PointedEars
Jul 20 '05 #10
Thomas 'PointedEars' Lahn wrote:
<snip>
The References header of his posting is OK.


Yes I know. I think I hit the wrong message when I activated the view
source opting on my newsreader and confused myself by expecting a
forum4designers post to be wrong when they may actually have fixed the
References aspect of their software. (Which may just leave the
undesirable prefixing of "Re: " to the subject header of original posts
as the only obvious error remaining).

Richard.
Jul 20 '05 #11

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

Similar topics

0
2475
by: And | last post by:
I use shdocvw InternetExplorer Object to open a pdf file and then I want to automatically save it but the web site from wich I'm downloading the file doesn't allows to save the file using the...
2
2780
by: iloveprincess | last post by:
Hi, I'm developing windows application using VB.Net 2005. I would like to send 'save' message using 'SendMessage' API to the excel appication. I've already got a handle of the excel window with...
3
1330
by: indhu | last post by:
Private Sub cmdsave_Click() If imagebox.Picture = LoadPicture("") Then MsgBox "Please browse the image you want to add to your database.", vbExclamation, "Image required" browseimage ...
12
4742
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...
2
64453
by: Ian | last post by:
I am trying to save the current record on a form before opening a report, doesn’t sound to hard does it? The code on a buttons on click event goes like this: DoCmd.DoMenuItem acFormBar,...
1
6085
by: QCLee | last post by:
Hello Sir, Im here again asking for help. I have a form and a subform relate to HVAC Windward Table. i have a SAVE button on the form that when clicked it saves data on the HVAC Windward Table but...
1
1783
by: pdxrichard | last post by:
Windows XP - Server 2003 - Access 2007 VBA - Code behind a form Here is my code. Why can't I find the exported file if the directories exist and there are no permission problems? Isn't a save...
10
1445
by: epp319 | last post by:
Hi! i am i trying to make o vb program and i have a big problem. I have a combination of forms into i put some keywords and i transfer data from one form into an other (from text to text or from...
0
238
by: Terry Reedy | last post by:
Ty hensons wrote: On Windows, 2.4?+, right click upper left snake symbol, Edit/Select all (or Mark and select part), <enter(not ^C as everywhere else -- thank MS for not following its standard)...
4
3453
by: Ezzz | last post by:
I have customised a form to display my own error messages using:- Private Sub Form_Error(DataErr As Integer, Response As Integer) ' If an error occurs because of duplicate data in a required...
0
6904
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
7037
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
6735
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
6895
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
5326
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
4476
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...
0
2992
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.