I want to save a开发者_如何转开发 HTML page using JavaScript in Firefox.
I've tried the code below, but it only works in IE:function doSaveAs() {
if (document.execCommand) {
document.execCommand("SaveAs");
}
}
This only works in IE.
Simply tell the user to hit CTRL+S if he wants to save a page. You could also link to a php script which sends the page with appropriate headers (Content-Disposition: attachment; filename="document.html"
) forcing a download window if all the user should save is the HTML page (i.e. without any images, css, etc.).
精彩评论