Help - Search - Members - Calendar
Full Version: Save Ie7 Web Page As A Word File
BleepingComputer.com > Internet & Networking > Web Site Development
   
Baptong
I am using this document.execCommand('SaveAs') and when I do document.execCommand('SaveAs', 'true', 'word_file.doc'), nothing happens. Anyone know how to save Web page as a Word document? Either as DOC or DOCX file extension.
groovicus
You are using the right syntax. What does the rest of your code look like?
Baptong
Well, to make it simple, my code looks like this in a nutshell

<html>
<head>
<title>
</title>
<script language="Javascript">
function save_as()
{
document.execCommand('SaveAs', 'true', 'word_file.doc')
}
</script>
<body>
<input type="button" value="Save Form to the Local PC" onClick="save_as()"></input>
</body>
</html>

That button does not function nor does it bring up the Save As window.
groovicus
The code looks fine. So the stupid question is are you trying to run it in Firefox with script block on or anything like that?
Baptong
No, I am running it in Microsoft IE 7. Have you tried my code yourself? I am hoping it may be a user error on myself.
groovicus
I am getting this error:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLDocument.execCommand]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/Users/Public/Documents/test.html :: save_as :: line 8" data: no]
Baptong
Well, that is ODD.........

When I run it in IE 7, I had to allow the blocked content, and then I click on my button and nothing happens. Anyone else know something else? Or maybe even another forum where I can ask.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.