View Full Version : auto-save as in Win98
Graeme Hackston
09-30-2002, 03:53 AM
This is very likely the wrong forum but I don't know what I need.
I've made a form that writes web page code to a textarea. I made it to automate offline page production. It works fine but I was wondering if there was something I could use to automatically save the completed file to my HD? I can generate a file name with javascript but what, if anything, can I use to save it?
Spookster
09-30-2002, 06:18 AM
You will need a server-side language to generate the files. PHP works.
Graeme Hackston
09-30-2002, 11:44 PM
Thanks Spookster
I don't know anything about PHP. Do I need to install something on my computer that will act like a server? Also, would you know where I could find a PHP script similar to what I need or alternatively a site with good tutorials?
joh6nn
10-01-2002, 12:54 AM
yeah, you would need to, for php, i think spookster misunderstood, and thought you were trying to do this on your site. you could get this to to work, by installing a server on your comp, and using a server side language, or you could use MS proprietary jscript extensions. however, i really think that's way more trouble than it's worth. in theory, having a program save this for you automatically would be faster, but how long is it going to take to set up a server, or learn to use the proprietary MS extensions? neither is easy. you're better of just having notepad open, and copy and pasting the results to notepad.
Spookster
10-01-2002, 12:59 AM
Aha. Yes you would need php and a webserver on your local system. If you went that route you can use phpdev:
http://codingforums.com/showthread.php?s=&threadid=3992
Graeme Hackston
10-01-2002, 06:42 AM
Thanks guys
I've already got it copied to the clipboard so it's just paste then save as in notepad. My server doesn't support PHP so I'll keep phpdev in mind for future reference.
Graeme Hackston
10-01-2002, 07:31 AM
I did a little more searching and came up with this (IE4+ only) from this page:
http://p2p.wrox.com/archive/javascript/2002-07/48.asp
<html>
<head>
<script>
function save() {
str = document.forms[0].textarea.value;
mydoc = document.open();
mydoc.write(str);
mydoc.execCommand("saveAs",true,"mydocument.htm");
mydoc.close();
}
</script>
</head>
<body>
<form>
<textarea name="textarea" rows="1" cols="20"></textarea>
<input type="button" value="save" onclick="save()">
</form>
</body>
</html>
Graeme Hackston
10-01-2002, 10:06 AM
Here's a better one but I'm wondering if anyone knows how to disable the ActiveX prompt when requests are made from my computer (i.e. offline)?
http://www.webreference.com/js/tips/001031.html
Graeme Hackston
10-05-2002, 09:41 PM
Just an update. Here's what I decided to use:
<html>
<head>
<title></title>
<script>
function SavePage() {
var page = "c:\\My Documents\\page.htm";
var Iframe = window.frames[0];
var Code = '<html>\n';
Code += 'blah blah blah\n';
Code += 'blah blah blah';
Iframe.document.open();
Iframe.document.write(Code);
Iframe.document.execCommand("saveAs",true,page);
Iframe.document.close();
window.location.reload(); // auto reload form page after save
}
</script>
</head>
<body>
<input type ="button" Value="Save Page" onClick="SavePage()">
<iframe src="iframe_dummy.htm" style="display: none"></iframe>
</body>
</html>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.