Enable JavaScript Save As "Webpage Complete"
If you do the normal way to show the SaveAs dialog box from JavaScript like below, you are limited to what you can save. “document.execCommand” is the API that you should used.
function doSaveAs(){
if (document.execCommand){
if (isReady){document.execCommand("SaveAs", true);}
}else{
alert('Feature available only in Internet Exlorer 4.0 and later.');
}
}
What if you want to go beyond that and able to save the complete website with images? You can do as below with a piece of advice, it works only in Microsoft Internet Explorer. In fact the top way doesn't work in firefox too haha!
function ShowSaveComplete() {
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("This is only applicable to Internet Explorer");
}
}
Looks hardcore right J Hope you find this useful. It might not be the best way to achieve the best result.