开发者

Save a HTML page in Firefox using JavaScript

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.).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜