Entry
Can Save As type be made "Web Page, complete (*.htm;*.html)" by default using document.execCommand()
Sep 14th, 2005 04:39
Yves Jaques, Sanjeev Jain,
I actually thought this was impossible, but I found a solution by:
Olivier Chazelle
I've tested it and it works! Add the script to your head and then call
it from an onclick (like a button labelled "save" for example.
Try this (IE only)
function enregistre() {
if (document.all) {
var OLECMDID_SAVEAS = 4;
var OLECMDEXECOPT_DONTPROMPTUSER = 2;
var OLECMDEXECOPT_PROMPTUSER = 1;
var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0
CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
WebBrowser1.ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_PROMPTUSER);
WebBrowser1.outerHTML = "";
} else {
alert("Sorry, your browser does not support this feature. Save the web
page from the FILE menu of your browser.");
}
}