开发者

Save a HTML page in Firefox using JavaScript

开发者 https://www.devze.com 2023-02-28 18:18 出处:网络
I want to save a开发者_如何转开发 HTML page using JavaScript in Firefox. I\'ve tried the code below, but it only works in IE:

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

精彩评论

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

关注公众号