用js保存页面指定内容
2015-10-23 11:06
405 查看
用js保存页面指定内容
转自: http://rorchina.iteye.com/blog/184425
Html代码
<script language=javascript>
function Save(){
var txt = document.all.output.value;
b = window.open();
b.document.open();
b.document.write(txt);
b.document.close();
b.document.execCommand('saveas',true,'output.html');
b.window.close();
}
</script>
<center>仅保存文本框中部分:</center>
<table width="90%" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>不保存</td>
<td><input type="button" value="Save" class="trans" onclick="Save()">
<textarea rows="20" cols="50" id="output" class="txtedit"></textarea>
</td>
</tr>
</table>
保存HTML中的Table到Excel中
转自:http://www.bcbbs.net/news/Content28841.aspx
Html代码
<html>
<head>
<title>保存HTML中的Table到Excel中</title>
</head>
<body>
<h1>保存内容到Excel中</h1>
<table id='content'>
<tr><td>列1</td><td>列2</td></tr>
<tr><td>a1</td><td>a2</td></tr>
<tr><td>b1</td><td>b2</td></tr>
<tr><td>c1</td><td>c2</td></tr>
<tr><td>d1</td><td>d2</td></tr>
<tr><td>e1</td><td>e2</td></tr>
<tr><td>f1</td><td>f2</td></tr>
</table>
<a href="javascript:downloadfile('content')">保存文件</a>
<script language="javascript">
function downloadfile(id)
{
window.document.write(document.getElementById(id).outerHTML);
window.document.execCommand("SaveAs",false,"C:\\download.xls");
history.go(-1);
}
</script>
</body>
</html>
转自: http://rorchina.iteye.com/blog/184425
Html代码
<script language=javascript>
function Save(){
var txt = document.all.output.value;
b = window.open();
b.document.open();
b.document.write(txt);
b.document.close();
b.document.execCommand('saveas',true,'output.html');
b.window.close();
}
</script>
<center>仅保存文本框中部分:</center>
<table width="90%" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>不保存</td>
<td><input type="button" value="Save" class="trans" onclick="Save()">
<textarea rows="20" cols="50" id="output" class="txtedit"></textarea>
</td>
</tr>
</table>
保存HTML中的Table到Excel中
转自:http://www.bcbbs.net/news/Content28841.aspx
Html代码
<html>
<head>
<title>保存HTML中的Table到Excel中</title>
</head>
<body>
<h1>保存内容到Excel中</h1>
<table id='content'>
<tr><td>列1</td><td>列2</td></tr>
<tr><td>a1</td><td>a2</td></tr>
<tr><td>b1</td><td>b2</td></tr>
<tr><td>c1</td><td>c2</td></tr>
<tr><td>d1</td><td>d2</td></tr>
<tr><td>e1</td><td>e2</td></tr>
<tr><td>f1</td><td>f2</td></tr>
</table>
<a href="javascript:downloadfile('content')">保存文件</a>
<script language="javascript">
function downloadfile(id)
{
window.document.write(document.getElementById(id).outerHTML);
window.document.execCommand("SaveAs",false,"C:\\download.xls");
history.go(-1);
}
</script>
</body>
</html>
相关文章推荐
- jsf 实例代码
- 仿淘宝分页按钮效果简单美观易使用的JS分页控件
- jsf web.xml配置解析
- js中的escape()、encodeURI()和encodeURIComponent()
- JS escape、encodeURI 、encodeURIComponent 编码与解码
- 深入理解JavaScript定时机制
- js判断手机号运营商的方法
- JS字符串大小写转换实现方式
- js计算文本框输入的字符数
- javascript中prototype的理解
- 正确使用JS中的正则
- 日常收集JS邮箱验证正则表达式
- js封装id与class选择器代码,兼容ie低版本
- Asm.js
- JS实现超简洁网页title标题跑动闪烁提示效果代码
- (三)seajs中的模块标识
- 关于js动态生成元素,注册(绑定)的事件失效的解决(on)
- asp.net中javascript与后台c#交互
- Java 和 JavaScript 是什么关系?
- 犀牛书上的js贷款计算器(已经过调试)