473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Issues with the document.execCommand("SaveAs")

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
6 22931
BigDaddyLH
1,216 Expert 1GB
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
JosAH
11,448 Expert 8TB
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
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
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
1,216 Expert 1GB
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
16,027 Expert Mod 8TB
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

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

Similar topics

4
by: Microsoft | last post by:
I'm trying to display a word document inside a web page, but everytime I do I get this error: Error Type: Microsoft VBScript runtime (0x800A0046) Permission denied: 'CreateObject' Does...
3
by: lir | last post by:
Hi, I am trying to save a fram in a page using the execCommand("saveas") the html is save currectly but I can not save the gif on that page. How can I save the fram with the gif via...
4
by: Otis Hunter | last post by:
I have been fighting with this for days and your expert help is needed! Below is the code I am executing which results with "Object doesn't support this property or method". The error is occuring...
1
by: suitland | last post by:
Hi All, I am using the execCommand(SaveAs) function to save an HTML file as an xls file, and works fine when I open the program and open the file. Is there anyway I can trigger an Open dialog box...
2
by: psanjay | last post by:
Hi, Am unable to open javascript SaveAs dialog box in Firefox browser. Following is the script, <a href="javascript:void(0);" onclick="document.execCommand('SaveAs',false,'*.xyz');">Save this...
4
by: GavReynolds | last post by:
Hi All! I am using Javascript to export some content in a popup (in this case, just 5 simple words) to a text file. This works fine and the user can save the text file. Upon opening the file,...
2
by: ejrfigueiredo | last post by:
Hi, Is there a way to get a script function to save a page without the execCommand (which works on IE but doesn't on Firefox). Below there's the code I'm using, I took it from a template page...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.