使用JavaScript在Firefox中保存HTML页面 [英] Save a HTML page in Firefox using JavaScript
本文介绍了使用JavaScript在Firefox中保存HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试过下面的代码,但是它只能在IE中使用:
函数doSaveAs(){
if(document.execCommand){
document.execCommand(SaveAs);
$ / code $ / pre
解决方案只适用于IE。
只要告诉用户如果他想保存一个页面就按CTRL + S。你也可以链接到一个PHP脚本,该脚本用适当的头文件( Content-Disposition:attachment; filename =document.html
)发送页面,强制下载窗口用户应该保存的是HTML页面(即没有任何图像,CSS等)。
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.).
这篇关于使用JavaScript在Firefox中保存HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文