By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,666 Members | 1,909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,666 IT Pros & Developers. It's quick & easy.

Issues with the document.execCommand("SaveAs")

P: 3
Hey guys, wondered if anybody could help me out with a pretty simple piece of code that has been driving me crazy for the past few days?

I am trying to create a client side self sustaining message board system using basic DHTML to keep all of my colleges up to date.

I have successfully built functions to control the posting of messages, but as I try to create a method which completes an overwrite/save as command over the same html file I run into some issues.

I am currently using the following code to complete this task:

function saveChanges()
{
var newHtml = document.documentElement.outerHTML;

document.open("text/html","replace");
document.write(newHtml);
document.close();
document.execCommand("saveas", false, "C:/Documents and Settings/Matt/My Documents/Projects/iSpace/users/default.htm");

}

Despite defining the execCommand line as best as possible, the save function continues to call the save as prompt box which I am trying specifically to avoid.

I need to have the current page overwrite the old page (default.htm) upon activating this function in the defined directory with no "save as" prompt.

The current code does save the file once the user points the save function into the correct directory using the prompt so as far as I can tell, it is only the execCommand line I must have incorrect.

Any ideas people?
Dec 26 '07 #1
Share this Question
Share on Google+
6 Replies


BigDaddyLH
Expert 100+
P: 1,216
A lot of people make this mistake: you're asking about JavaScript, which is a scripting language unrelated to the programming language Java. Just as there is no dog in a "hotdog", there is no Java in JavaScript.

Try the JavaScript forum.
Dec 26 '07 #2

Expert 10K+
P: 11,448
I apologize for temporarily hijacking this thread: @BDLH: did you read my PM?
Interested? Back to the scheduled programme again.

kind regards,

Jos
Dec 26 '07 #3

P: 3
Hey guys, wondered if anybody could help me out with a pretty simple piece of code that has been driving me crazy for the past few days?

I am trying to create a client side self sustaining message board system using basic DHTML to keep all of my colleges up to date.

I have successfully built functions to control the posting of messages, but as I try to create a method which completes an overwrite/save as command over the same html file I run into some issues.

I am currently using the following code to complete this task:

Expand|Select|Wrap|Line Numbers
  1. function saveChanges()
  2. {
  3. var newHtml = document.documentElement.outerHTML;
  4.  
  5. document.open("text/html","replace");
  6. document.write(newHtml);
  7. document.close();
  8. document.execCommand("saveas", false, "C:/Documents and Settings/Matt/My Documents/Projects/iSpace/users/default.htm");
  9.  
  10. }
  11.  
Despite defining the execCommand line as best as possible, the save function continues to call the save as prompt box which I am trying specifically to avoid.

I need to have the current page overwrite the old page (default.htm) upon activating this function in the defined directory with no "save as" prompt.

The current code does save the file once the user points the save function into the correct directory using the prompt so as far as I can tell, it is only the execCommand line I must have incorrect.

Any ideas people?
Dec 26 '07 #4

P: 3
A lot of people make this mistake: you're asking about JavaScript, which is a scripting language unrelated to the programming language Java. Just as there is no dog in a "hotdog", there is no Java in JavaScript.

Try the JavaScript forum.
apologies, new to this...
Dec 26 '07 #5

BigDaddyLH
Expert 100+
P: 1,216
I apologize for temporarily hijacking this thread: @BDLH: did you read my PM?
Interested? Back to the scheduled programme again.

kind regards,

Jos
D'oh! So that's what a PM is!
Dec 27 '07 #6

acoder
Expert Mod 15k+
P: 16,027
The prompt is there for security reasons. You could possibly get an IE-only solution, e.g. this link - not tested and don't know if it works in the latest versions of IE.
Dec 27 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.