这个功能是不是用JS可以做到,高手请进

来源:百度知道 编辑:UC知道 时间:2024/05/21 14:15:48
一个按钮,点击之后立即复制网页的源文件,怎么做?如果回答好,本人将加50,thanks very much.先放上20

<script language="javascript">
function copy()
{
document.getElementById("input1").value=document.body.innerHTML;
document.getElementById("input1").select();
document.execCommand("copy")
}
</script>
<body>
<input id="input1" type="text" style="width:0;height:0;" value="">
<input type="button" onclick="copy()" value="复制">
<input type=button value=刷新 onclick="window.location.reload()">
</body>

以上是取body中的代码 取全代码如下
同一楼!

document.documentElement.outerHTML获取页面所有代码

IE的DHTML对象提供了四个可读写的属性来动态操作页面元素的内容:innerText, outerText, innerHTML, outerHTML.需注意两点:1. 其中innerText,outerText属性的值是作为普通文本呈现的,即使它含有HTML标签也如实反应出来;2. InsertAdjacentText只能插入普通文本,InsertAdjacentHTML插入html格式的文本3. 用InsertAdjacentHTML插入脚本,必须在script元素中使用defer属性,否则脚本执行将出现运行期错误