把html页面的部分内容保存成新的html文件的jquery代码
作者:bea
代码如下: //保存聊天记录到本地 function save_record() { //取得当前日期作为文件名 var time=new Date(); var filename=time.toLocaleDateString(); //获取当前页面部分内容 var record=$("#contentList").html(); //打开新窗口保存 var winRecord=window.open('about:blank','_blank','
代码如下:
//保存聊天记录到本地
function save_record()
{
//取得当前日期作为文件名
var time=new Date();
var filename=time.toLocaleDateString();
//获取当前页面部分内容
var record=$("#contentList").html();
//打开新窗口保存
var winRecord=window.open('about:blank','_blank','top=500');
winRecord.document.open("text/html","utf-8");
winRecord.document.write("<html><style>body,ul,li{margin:0px; padding:0px;list-style:none; font-size:12px;}</style><body>"+record+"</body></html>");
winRecord.document.execCommand("SaveAs", true, filename+".html");
winRecord.close();
}
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- Dojo 学习笔记入门篇 First Dojo Example
- flash 得到自身url参数的代码
- javascript 去字符串空格终极版(支持utf8)
- jQuery checkbox全选/取消全选实现代码
- jQuery帮助之CSS尺寸(五)outerHeight、outerWidth
- jquery 可排列的表实现代码
- javascript 带有滚动条的表格,标题固定,带排序功能.
- 传智播客学习之JavaScript基础篇
- [原创]一段时间以后切换显示的广告代码
- 文字在网页上下浮动 学习可以不建议用
- JS溶解形式的文字切换特效
- Marquee配合DIV实现的文字滚动效果代码
- 用document.documentElement取代document.body的原因分析
- JQuery SELECT单选模拟jQuery.select.js
- Jquery操作Select 简单方便 一个js插件搞定
- jquery控制listbox中项的移动并排序
- Jquery 获取表单text,areatext,radio,checkbox,select值的代码
- 两个select之间option的互相添加操作(jquery实现)
- XHTML下,JS浮动代码失效的问题