View Full Version : Saving only a portion of webpage into a file

04-29-2006, 01:52 PM
im working on a web application that generates dynamic data. My question is: i want users to be able to save the generated data, but not the whole web page, just a table in the web page that holds this data. I searched and found out that showing a "save as" dialog box is possible with javascript, with a method like: onclick="javascript: document.execCommand('SaveAs','1',null);. However, i coulnd't find out how to change the document object (or is it possible?) or a trick to print just the table of dynamic data. I tried to cover the table with <div id="myData"></div> and use onclick="javascript: myData.execCommand('SaveAs','1',null); but as you might guess, it didn't work and gave this error message: "object doent support this property or method". Indeed i dont have any idea what div tag can and can't do, so it was just a meaningless try. By the way, i want to add that i can't use iframes just because of program design issues.
Anyway, do you have any suggestions?

thanks in advance,
ibrahim saygılı

04-29-2006, 10:54 PM
Can you use window.open()?

04-29-2006, 11:00 PM
The only file access that javascript has is to read and write cookies.

execCommand is an Internet Explorer only command for use on intranets.

04-29-2006, 11:15 PM
Actually felgall, Mozilla has partial support for execCommand() (http://www.mozilla.org/editor/midas-spec.html), but it doesn't support execCommand('SaveAs', [...]).