网页JS代码:保存本页 打印本页 关闭本页

网页JS代码:保存本页 打印本页 关闭本页

 

<html>
<head>
<script language="JavaScript">

//保存本页代码共3处
// script 脚本放到 head
//body onLoad="isReady=true"
//<a href="javascript:doSaveAs()">保存本页</a>
var isReady = false;
function doSaveAs(){
if (document.execCommand){
if (isReady){document.execCommand("SaveAs");}
}else{
alert('Feature available only in Internet Exlorer 4.0 and later.');
}
}
</script>
</head>
<body onLoad="isReady=true">
<!--//保存本页代码共3处
// script 脚本放到 head
//body onLoad="isReady=true"
//<a href="javascript:doSaveAs()">保存本页</a>
-->
<a href="javascript:doSaveAs()">保存本页</a>
<a onclick=window.print() style="cursor:hand">打印本页页</a> 
<a onclick="window.opener=null" href="javascript:window.close()">关闭本页</a>

</body>

 

保存也可以这样:document.execCommand("SaveAs",filename);

你可能感兴趣的:(网页JS代码:保存本页 打印本页 关闭本页)