[Javascript] Caching the js files
David T. Lovering
dlovering at gazos.com
Thu Mar 20 17:37:54 CST 2003
As a postscript to the earlier remarks I made, I just worked out a rather
slick method of writing ANY kind of file from JavaScript (client side),
using a rather obscure command 'execCommand'. Normally the SaveAs command
does bring up a dialogue to confirm the process, but by setting userGUI
to false, you can beat that and save invisibly.
Cute trick -- the only downside is that you can only save a JavaScript
document. The solution is to create a blank document in a remote window
spawned as scratch-paper, and then save the contents once you've filled
it with whatever needs saving. Something like this might do the trick
win.document.execCommand("SaveAs", false, "C:\temp\myfile.txt");
where win is the bogus window we created just for the purposes of writing
to it by means of lots and lots of win.document.write(...); commands. Be
sure to do a win.document.close() when you're done writing and before you
do the "SaveAs", or else you might lose the tail end of what you'd intended
to keep.
The confirmation message uses a standard child window with the usual
OK or cancel buttons. It is easy to find out the windowID from the window
manager, and then do a remote button-click on the "OK" button in the remote
to send it on its way. No need to actually use your greasy finger!
-- Dave Lovering
"David T. Lovering" wrote:
>
> Dear DEV:
>
> I was thinking perhaps of uploading the history onto the server, or else
> doing a 'write-back' cookie to your own machine. It is relatively easy to
> write cookies as needed, and providing your history file isn't huge the
> cookie (which can contain compressed data) will hold quite a lot.
>
> In theory, the fileUpLoad process requires the user to confirm the transfer,
> but in point of fact the use of I/O redirection can fake a user's acceptance
> (the approval is usually managed by way of an OK button, and we all know how
> to automaticly press buttons now, don't we?). I've built automatic backup
> and form-saving utilities which write to the server without the user being
> any the wiser -- unless the data is corrupted, and they need the backup. Then
> they are grateful that the service exists!
>
> I might also mention that file downloads are easy to manage from the server,
> and if it is imperative that you save your history to your own machine you can
> do an end-run by shipping the file uphill to the server, which then does some
> fancy footwork to direct the output by way of a pipe back to a file on your
> drive. You will get a file progress notice (no way to suppress that), but the
> end result is that you get what you want.
>
> -- Dave Lovering
>
> DEV wrote:
> >
> > >> references
> > I want to save, and then append them to a free-running file in a 'safe'
> > directory.
> >
> > I do not think JS has client side file saving capability unless client ( the
> > visitor ) allows this happening ? Am I not correct ?
> >
> > ----- Original Message -----
> > From: "David Lovering" <dlovering at gazos.com>
> > To: <javascript at LaTech.edu>
> > Sent: Wednesday, March 19, 2003 8:28 PM
> > Subject: Re: [Javascript] Caching the js files
> >
> > > Lots of ways are feasible, but before closing out the window where the
> > > JavaScript process is running, I'd parse the 'history' table for
> > references
> > > I want to save, and then append them to a free-running file in a 'safe'
> > > directory. Then, when the cache gets flushed my 'backup' copy is left
> > > untouched and can be referenced again during a later session.
> > >
> > > -- Dave Lovering
> > >
> > > ----- Original Message -----
> > > From: "DEV" <dev at qroute.net>
> > > To: <javascript at LaTech.edu>
> > > Sent: Wednesday, March 19, 2003 4:29 PM
> > > Subject: [Javascript] Caching the js files
> > >
> > >
> > > > How do you cache a page where the caching of all the JS ( the <script
> > > > src='myFile.js'></script> ) files are cached only for that session ?
> > > >
> > > > _______________________________________________
> > > > Javascript mailing list
> > > > Javascript at LaTech.edu
> > > > https://lists.LaTech.edu/mailman/listinfo/javascript
> > > >
> > >
> > >
> > > _______________________________________________
> > > Javascript mailing list
> > > Javascript at LaTech.edu
> > > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> Name: dlovering.vcf
> dlovering.vcf Type: VCard (text/x-vcard)
> Encoding: 7bit
> Description: Card for David T. Lovering
>
> Part 1.3 Type: Plain Text (text/plain)
> Encoding: 7bit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dlovering.vcf
Type: text/x-vcard
Size: 304 bytes
Desc: Card for David T. Lovering
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20030320/a3e07cf1/attachment.vcf>
More information about the Javascript
mailing list