I have a website and I have a textarea for user to key in text, how can i create a "save as button" that allow user to save what they had key in .htm format?
-- this script got from www.javascriptfreecode.com-Coded by: Krishna Eydatoula -->
<script>
// CREDITS:
// salar mehrabi
// Copyright (c) 2003 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.javakhafan.9f.com
// IMPORTANT:
// If you add this script to a script-library or a script-archive
// you have to insert a link to http://www.javakhafan.9f.com
// right into the webpage where the script will be displayed.
function doSaveAs(){
if (document.execCommand){
document.execCommand("SaveAs")
}
else {
alert("Save-feature available only in Internet Exlorer 5.x.")
}
}
</script>
<form>
<input type="button" value="Save This WebPage" onClick="doSaveAs()"
</form>
<br>
<font face="Tahoma"><a target="_blank" href="http://www.javascriptfreecode.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
However, this code is only work in IE, It's not work in FireFox.
I would appreciate if someone can give me an advice.
You really need to use a server side language and save to a database. OR if the text area is small enough you can save the info in a cookie (can save up to about 4000 characters)
Also, why do you need a "Save As" ?
What the users do with this information ?
Will they need to reload this back into the text area ?
Will they need to print this info ?
Bookmarks